Hi everyone, having trouble with one line of code. I think I'm pretty close to figuring out this macro. I'm getting the following error:
"Run-time error '438':
Object doesn't support this property or method"
on this line of code: wbMstr.wsMstr.Range("c1").End(xlDown).Offset(1, 0).Select
How can I better define my method? Thanks!
Sub ImportCSVsWithReference()
'Summary: Import all CSV files from a folder into a single sheet
' adding a field in column A listing the CSV filenames
Dim wbCSV As Workbook
Dim wbMstr As Workbook: Set wbMstr = ThisWorkbook
Dim wsMstr As Worksheet: Set wsMstr = ThisWorkbook.Sheets("Sheet1")
Dim fPath As String: fPath = "C:\Users\Eddie\Dropbox\Admob pull Data\Admob pull Data(eddie)\8.17\" 'path to CSV files, include the final \
Dim fCSV As String
'If MsgBox("Clear the existing MasterCSV sheet before importing?", vbYesNo, "Clear?") _
'= vbYes Then wsMstr.UsedRange.Clear
Application.ScreenUpdating = True 'speed up macro
fCSV = Dir(fPath & "*.csv") 'start the CSV file listing
Do While Len(fCSV) > 0
'open a CSV file
Set wbCSV = Workbooks.Open(fPath & fCSV)
wbCSV.ActiveSheet.Range(Range("a3:h3"), Range("a3").End(xlDown)).Copy
wbMstr.wsMstr.Range("c1").End(xlDown).Offset(1, 0).Select
wbCSV.Close False
'ready next CSV
fCSV = Dir
Loop
Application.ScreenUpdating = True
End Sub
Bookmarks