chipsworld
Board Regular
- Joined
- May 23, 2019
- Messages
- 169
- Office Version
- 365
Hi all,
Not sure what I am doing here... I am trying to figure out how to copy data from one workbook (single sheet) to another workbook (1 sheet). The problem is that I have 5 columns of data on the source sheet, and multiple rows of data to copy. The column header is a date and the row data is a simple title.
I need to be able to select the source workbook, and copy the data from that workbook/sheet to the master workbook.
I have been researching how to use Match and Index, but can not figure out how to do it... Honestly, it is making me crazy.
I have the code to open the source workbook (below), but am completely lost on how to do the match and copy to the master workbook...
Any help would be greatly appreciated. I just need something generic that I can work with to get me running in the right direction...
Thanks!
Not sure what I am doing here... I am trying to figure out how to copy data from one workbook (single sheet) to another workbook (1 sheet). The problem is that I have 5 columns of data on the source sheet, and multiple rows of data to copy. The column header is a date and the row data is a simple title.
I need to be able to select the source workbook, and copy the data from that workbook/sheet to the master workbook.
I have been researching how to use Match and Index, but can not figure out how to do it... Honestly, it is making me crazy.
I have the code to open the source workbook (below), but am completely lost on how to do the match and copy to the master workbook...
Any help would be greatly appreciated. I just need something generic that I can work with to get me running in the right direction...
Thanks!
VBA Code:
Dim wbThisWB As Workbook
Dim wbImportWB As Workbook
Dim strFullPath As String
Dim i As String
Dim m As Variant
Dim result As String
Set wbThisWB = ThisWorkbook
With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = False
.Title = "Please select a file to import:"
.Filters.Add "Excel and CSV files", "*.csv; *.xls; *.xls*", 1
.Show
On Error Resume Next 'In case the user has clicked the <Cancel> button
strFullPath = .SelectedItems(1)
If Err.Number <> 0 Then
Exit Sub 'Error has occurred so quit
End If
On Error GoTo 0
End With
Set wbImportWB = Workbooks.Open(strFullPath)
Application.ScreenUpdating = False
result = VLookup(wbImport.Sheets("data").cell(i, 1), wbThisWB.Sheets("S1 Daily Metrics"), Match(col_name, col_headers, 0), 0) [B]' was working with this, but honesltly can't figure out what to do with it, or how to use it correctly...[/B]
Application.ScreenUpdating = True