VBA paste special Values Issue

thelad

Board Regular
Joined
Jan 28, 2011
Messages
245
Hi,

I have the following code working and it moves data from certain columns to another column on a different sheet. The below code works but soe of these columns have formula's in them. Do you know how to move paste Special values

I tried the following as a test but it doesnt work.

Does nyone know whats to be done to paste special values using below code?

src.Range("B:B").Copy Destination:=trg.Range("A1").PasteSpecial


PHP:
Sub Test()
    Dim src As Worksheet    Dim trg As Worksheet    Dim LastRow As Long

    Set src = ThisWorkbook.Worksheets("Test")    Set trg = ThisWorkbook.Worksheets("Copy")


    src.Range("B:B").Copy Destination:=trg.Range("A1")            src.Range("F:F").Copy Destination:=trg.Range("B1")

    src.Range("U:U").Copy Destination:=trg.Range("C1")    
    End Sub
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Try this.
Code:
Sub Test()
Dim src As Worksheet    Dim trg As Worksheet    Dim LastRow As Long

    Set src = ThisWorkbook.Worksheets("Test")    
    Set trg = ThisWorkbook.Worksheets("Copy")


    src.Range("B:B").Copy 
    trg.Range("A1").PasteSpecial xlPasteValues

    src.Range("F:F").Copy
    trg.Range("B1").PasteSpecial xlPasteValues

    src.Range("U:U").Copy
    trg.Range("C1").PasteSpecial xlPasteValues

End Sub
 
Upvote 0
Try this

Instead of copy and paste three time, copy and paste in one go

Code:
Sub Test()
Dim src As Worksheet    Dim trg As Worksheet    Dim LastRow As Long

    Set src = ThisWorkbook.Worksheets("Test")    
    Set trg = ThisWorkbook.Worksheets("Copy")


    src.Range("B:B,F:F,U:U").Copy 
    trg.Range("A1").PasteSpecial xlPasteValues

    Application.CutCopyMode = False


End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,338
Messages
6,124,357
Members
449,155
Latest member
ravioli44

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