I have messed something up!
I have altered the code as follows (to change the csv slightly) as follows:
Do While Len(fCSV) > 0
'open a CSV file
Set wbCSV = Workbooks.Open(fPath & fCSV)
'insert row 1 and add CSV name
Rows(1).Insert xlShiftDown
Range("E1") = ActiveSheet.Name
KountRows = Application.CountA(Range("A:A"))
KountRows = KountRows + 1
ActiveCell.EntireColumn.Offset(0, 3).Insert
Range("D3").Select
ActiveCell.FormulaR1C1 = "=RC[-2]+RC[-1]"
Selection.Copy
Range("D4:D" & KountRows).Select
ActiveSheet.Paste
Range("D3:D" & KountRows).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Selection.NumberFormat = "dd/mm/yyyy hh:mm:ss"
Columns("A:C").Select
Selection.Delete Shift:=xlToLeft
Range("A2") = "DateTime"
'copy date into master sheet and close source file
ActiveSheet.UsedRange.Copy wsMstr.Cells(1, NextCol)
wbCSV.Close False
'ready next CSV
fCSV = Dir
NextCol = wsMstr.Cells(3, Columns.Count).End(xlToLeft).Column + 3
Loop
ActiveSheet.UsedRange.Copy wsMstr.Cells(1, NextCol) gives me the error:
Application-defined or object-defined error.
I get this if I hover the mouse over wsMstr.Cells(1, NextCol)
What have I done wrong?
Bookmarks