vba, force Copy to paste values

Daktari

Board Regular
Joined
May 20, 2012
Messages
56
Sorry, please ignore. I discovered the solution a min after I posted here. I just needed the .pastespecial on a second line

I thought I'd ask for an answer to my brain freeze. I've some leftover code I'm reusing.
I'm copying some cells between sheets, and it's copying the whole cell reference.

How can I tweak it to copy values only? Hamfisting in .pastespecials havn't worked for me.

Code partial (the code works, I'm just not getting the paste values thingy)
Code:
For Each r In rng1
    If Not IsEmpty(r.Value) Then
        Set c = rng2.Find(r.Value)
        If Not c Is Nothing Then
            r(, 2).Copy c(, 2)
            r(, 6).Copy c(, 7) 
        End If
    End If
Next
 
Last edited:

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
like this?

Code:
For Each r In rng1
    If Not IsEmpty(r.Value) Then
        Set c = rng2.Find(r.Value)
        If Not c Is Nothing Then
            c.Offset(, 2).Value = r.Offset(, 2).Value
            c.Offset(, 7).Value = r.Offset(, 6).Value
        End If
    End If
Next
 
Upvote 0
No, I solved it like this:

Code:
 For Each r In rng1
    If Not IsEmpty(r.Value) Then
        Set c = rng2.Find(r.Value)
        If Not c Is Nothing Then
            r(, 2).Copy
            c(, 2).PasteSpecial Paste:=xlPasteValues
            r(, 6).Copy
            c(, 7).PasteSpecial Paste:=xlPasteValues
        End If
    End If
Next
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,774
Members
452,353
Latest member
strainu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top