Hello, I am brand new to VBA and I have some code to transfer data from multiple spreadsheets into one master spread sheet. This works ok but at the end I need to clear the days data from each of the spreadsheets so the data can be transferred again the next day with out duplicating. Is there something simple I can add to the end of my script to clear all the data I have just transferred? I know this should be easy but I just can get over this last hurdle. Any help would be very greatly appreciated
Here is my script so far:
Sub LoopThroughDirectory()
Dim MyFile As String
Dim erow
Dim Filepath As String
Filepath = "C:\Users\Guy\Desktop\nichola\"
MyFile = Dir(Filepath)
Do While Len(MyFile) > 0
If MyFile = "ZMASTER.xlsm" Then
Exit Sub
End If
Workbooks.Open (Filepath & MyFile)
Range("A2:E25").Copy
ActiveWorkbook.Close
erow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
ActiveSheet.Paste Destination:=Worksheets("Sheet1").Range(Cells(erow, 1), Cells(erow, 5))
MyFile = Dir
Loop
End Sub
Here is my script so far:
Sub LoopThroughDirectory()
Dim MyFile As String
Dim erow
Dim Filepath As String
Filepath = "C:\Users\Guy\Desktop\nichola\"
MyFile = Dir(Filepath)
Do While Len(MyFile) > 0
If MyFile = "ZMASTER.xlsm" Then
Exit Sub
End If
Workbooks.Open (Filepath & MyFile)
Range("A2:E25").Copy
ActiveWorkbook.Close
erow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
ActiveSheet.Paste Destination:=Worksheets("Sheet1").Range(Cells(erow, 1), Cells(erow, 5))
MyFile = Dir
Loop
End Sub