Excel VBA Extract columns to new workbook
This was originally a question raised in Microsoft Community and was answered by me.
I copied the original question below.
I’m sure my issue is not unique. I have a excel document with hundreds of columns and only want about a dozen of them. I need to be able to extract specific
columns to a new excel sheet as a repeated process without manual intervention.
All I need is to pull certain columns into a new excel sheet from an excel document that is updated daily.
Do we have an automated process where I can just run a macro and pull the updated data from an excel document into a new one?
Any help is greatly appreciated.
Solution: Excel VBA Extract columns to new workbook
Public Sub extractCol() Set range1 = Range("A:D, BI:BI, BQ:BQ,CL:CL,CM:CN,CT:CT,DB:DB") range1.Copy Set newbook = Workbooks.Add ActiveCell.PasteSpecial Paste:=xlPasteValues End Sub
Algorithm of the code
Step 1) group the desired columns as range1
Step 2) copy range1
Step 3) create a new workbook using Workbooks.Add
Step 4) paste to new workbook