Simple VBA - How to select & copy out of order columns to a different sheet

LNG2013

Active Member
Joined
May 23, 2011
Messages
466
I have a WB that has 200 columns, I want to select specific columns that are spaced out from each other, and paste them into a new worksheet.
I keep geting debug errors with the copy part highlighted. Any idea what I am doing wrong?


Code:
Sub ColumnsSelect()
'
Sheets("Objective5m").Select
    Range( _
        "I:I,L:L,N:N,P:P,Q:Q,R:R,T1,T:T,V:V,AA:AA,AF:AF,AI:AI,AJ:AJ,AK:AK,AL:AL,AM:AM,AN:AN,BP:BP,BR:BR,BW:BW,BU:BU,BX:BX,BY:BY,BZ:BZ,CA:CA,CB:CB,CC:CC" _
        ).Select
    Application.CutCopyMode = False
    [COLOR=red]Selection.Copy
[/COLOR]    Sheets("Sheet3").Select
    ActiveSheet.Paste
    
    
    
End Sub
 
Hi LNG2013,

I see you have T1,T:T. I guess that is a mistype? Remove that and it should work fine.

Regards,
 
Upvote 0
Dude you so rock! Also to note I had another error when it was performing the paste but that was because the sheet was selected but no cell area was.... Cells.Select


Finished code



Code:
Sub DataSelect()
'
' '
Sheets("Sheet1").Select
    Range( _
        "I:I,L:L,N:N,P:P,Q:Q,R:R,T:T,V:V,AA:AA,AF:AF,AI:AI,AJ:AJ,AK:AK,AL:AL,AM:AM,AN:AN,BP:BP,BR:BR,BW:BW,BU:BU,BX:BX,BY:BY,BZ:BZ,CA:CA,CB:CB,CC:CC" _
        ).Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Sheet2").Select
    Cells.Select
    ActiveSheet.Paste
    
End Sub
 
Upvote 0

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