Using copy and destination formatting

J

Jeff S.

I am using the following code to copy cells from page to page.
I would like them to match "Home Page" formatting. How can I do this?

If .Cells(r, 7) = 2 Then
Set cophyp = .Cells(r, 4)
With Worksheets("Home Page")
Set DestCell = .Cells(.Rows.Count, "G").End(xlUp).Offset(1, 0)
cophyp.Copy Destination:=DestCell
End With
End If

Thx, Jeff
 
J

Jacob Skaria

Use PasteSpecial (vaues) as below....Note that one line is remarked

If .Cells(r, 7) = 2 Then
Set cophyp = .Cells(r, 4)
With Worksheets("Home Page")
Set DestCell = .Cells(.Rows.Count, "G").End(xlUp).Offset(1, 0)
'cophyp.Copy Destination:=DestCell
cophyp.Copy
destcell.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
End With
End If



If this post helps click Yes
 
P

p45cal

orIf .Cells(r, 7) = 2 Then
Set cophyp = .Cells(r, 4)
With Worksheets("Home Page")
Set DestCell = .Cells(.Rows.Count, "G").End(xlUp).Offset(1, 0)
DestCell.Value = cophyp.Value
End With
End If
 
J

Jeff S.

Neither of these solutions (yours or the one below yours) transfers a
hyperlink in the cell properly but the formatting works. Any more thots?
 
P

p45cal

Neither of these solutions (yours or the one below yours) transfers a
hyperlink in the cell properly but the formatting works. Any mor
thots?Can I clarify; do you *just *want to copy hyperlinks (working) over
This would simplify things a lot
 
J

Jeff S.

Yes. Sorry I wasn't clear about that from the start. Copy and paste cells
containing hyperlinks to match destination formatting.
Thanks.
 
P

p45cal

If *only *the hyperlinks (there may be more than one per cell) the
try:If .Cells(r, 7) = 2 Then
Set cophyp = .Cells(r, 4)
With Worksheets("Home Page")
Set DestCell = .Cells(.Rows.Count, "G").End(xlUp).Offset(1, 0)
If cophyp.Hyperlinks.Count > 0 Then
For i = 1 To cophyp.Hyperlinks.Count
With cophyp.Hyperlinks(i)
Worksheets("Home Page").Hyperlinks.Add Anchor:=DestCell
Address:=.Address, TextToDisplay:=.TextToDisplay
End With
Next i
End If
End With
End I
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top