Copy selected columns and paste in a different worksheet

sahaider

New Member
Joined
May 30, 2014
Messages
35
Hello all,
Can anyone help me with this?
I would like to copy selected columns from a worksheet and paste it in cell A1 of another sheet.
the columns to be selected are columns B to D and column H and paste the copied contents in cell A1 of another sheet called TEST1.

Here is the code I have so far:

Range("B2:D2","H2").Select
Range(Selection, Selection.End(xlDown)).Select



Application.CutCopyMode = False
Selection.Copy

Worksheets("TEST1").Select
Range("A1").Select
ActiveSheet.Paste


The above code is not copying all the contents to the destination worksheet TEST1

Thanks
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Hi,

Quick solution -

VBA Code:
     ActiveSheet.Range("B:D").Copy Destination:=Worksheets("TEST1").Range("A1")
    ActiveSheet.Range("H:H").Copy Destination:=Worksheets("TEST1").Range("D1")

Thanks,
Saurabh
 
Upvote 0
Hello Sahaider,

Another option:-

VBA Code:
Sub Test()
        
        Dim ws1 As Worksheet: Set ws1 = Sheet1
        Dim wsT As Worksheet: Set wsT = Sheets("TEST1")
        
Application.ScreenUpdating = False

        wsT.UsedRange.Clear

        With ws1.[A1].CurrentRegion
               Union(.Columns("B:D"), .Columns("H")).Copy wsT.[A1]
        End With

Application.ScreenUpdating = True

End Sub


The code clears the "TEST1" sheet prior to each data transfer.
The code will also take the headings over to the "TEST1" sheet.
Please test it in a copy of your workbook first.

I hope that this helps.

Cheerio,
vcoolio.
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

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