I have code to loop through several sheets of data.
Dim MyFile As String
Dim erow
MyFile = Dir("C:\My Documents\Tester")
Workbooks.Open ("C:\My Docments\Tester\TestLog.xlsm")
Sheets("Master").Select
Rows("2:2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Delete Shift:=xlUp
Application.DisplayAlerts = False
Do While Len(MyFile) > 0
If MyFile = "ZMaster - Call Log.xlsm" Then
Exit Sub
End If
Workbooks.Open (MyFile)
Application.DisplayAlerts = False
Sheets("Calls").Activate
Range("A2:P2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
ActiveWindow.Close savechanges:=False
erow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
ActiveSheet.Paste Destination:=Worksheets("Master").Range(Cells(erow, 1), Cells(erow, 16))
I have two issues.
Firstly the macro fails unless the first workbook in the loop was "Saved As" by myself. Not Saved only Saved As. If I open the first workbook, click save as under the same file name then run the macro it works. I have developed a work around by the macro opening the first workbook and saving as.
Second and most importantly. My sub workbooks all have the date in English format. However when pasting to the Zmaster it is coming across as 12/01/16 rather than 01/12/16.