I have this code where it will merge all the files in a selected folder.
Sub simpleXlsMerger()
Dim bookList As Workbook
Dim mergeObj As Object, dirObj As Object, filesObj As Object, everyObj As Object
Application.ScreenUpdating = False
Set mergeObj = CreateObject("Scripting.FileSystemObject")
Set dirObj = mergeObj.GetFolder("C:\Documents and Settings\MergeData")
Set fileObj = dirObj.Files
For Each everyObj In fileObj
Set bookList = Workbooks.Open(everyObj)
Range("A2:IV" & Range("A65536").End(xlUp).Row).Copy
ThisWorkbook.Worksheets(1).Activate
Range("A65536").End(xlUp).Offset(1, 0).PasteSpecial
Application.CutCopyMode = False
bookList.Close
Next
End Sub
But I only want selected columns to be copied to the new workbook. I don't know what function or code to use to make that happen.
Example:
Workbook1
Name, Address, Postal Code, Age
Workbook2
Name, Address, Age, Occupation
In the new workbook I want the columns with
Name and Address only to be copied