Hi guys
I am dealing with survey data at the moment and i am interested in extracting data of 5 identical columns from 3 excel files and then aggregate them into one excel file.
below is the code im working on, fairly new to VBA so my apologies if my code doesnt make sense to you.
Sub extraction()
Dim a As Range
Dim r As Range
Dim wbSource As Workbook
Dim wbDestination As Workbook
Dim cumrow As Long
Set wbSource = Workbooks.Open("C:\Data extraction for Elieen\IVS_Trips.xlsx")
Set wbDestination = Workbooks.Open("C:\Data extraction for Elieen\1.xlsx")
cumrow = 0
ActiveWorkbook.Select
lastcol = Cells(1, Columns.Count).End(xlToLeft).Column
lastrow = Cells(Rows.Count, lastcol).End(xlUp).Row
Set r = Cells("AH1:AQ1").Resize(Rows.Count) ' This is your column
' Copy it to appropriate location on destination sheet
wbDestination.Sheets(1).Cells("AH1:AQ1").Resize(Rows.Count) = a
wbDestination.Sheets(1).Cells("AH1:AQ1").Resize(Rows.Count) = r
cumrow = cumrow + lastrow
End Sub
thanks in advance for your help.
Kind regards
Iverson
Bookmarks