Copy certain columns form a workbook to another with Macro

jevi

Active Member
Joined
Apr 13, 2010
Messages
339
Office Version
  1. 2016
Platform
  1. Windows
Dear All,

I am trying to copy the data from the workbook "Report 1", sheet: "First" , only the columns "A:A,J:J,U:U,V:V,W:W,Z:Z,AG:AG,AW:AW,BB:BB"
to the Workbook "Report 2.xlsm, Sheets"All" to the A2:K


But is not working as it is copying other columns that are close to each other...what I am doing wrong with the VBA?!

Thank you,

VBA Code:
Sub copyCols()

Application.ScreenUpdating = False
Dim LastRow As Long
Workbooks("Report 1.xlsx").Activate
LastRow = Sheets("Report 1").Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Sheets("First").Range("A:A,J:J,U:U,V:V,W:W,Z:Z,AG:AG,AW:AW,BB:BB").EntireColumn.Hidden = True
Range("A2:K" & LastRow).SpecialCells(xlCellTypeVisible).Copy Workbooks("Report 2.xlsm").Sheets("All").Cells(2, 1)
Sheets("First").Range("A:A,J:J,U:U,V:V,W:W,Z:Z,AG:AG,AW:AW,BB:BB").EntireColumn.Hidden = False
Application.ScreenUpdating = True

End Sub
 
It worked super super :). You are a genious...thank you so much:)).
 
Upvote 0

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,492
Messages
6,125,115
Members
449,206
Latest member
burgsrus

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