Hi All,
I currently run this macro on multiple documents in a folder. What I'd like to do is hide the worksheet - Sheet1 but still allow the macro to run.
Can anyone help with the below to allow the macro to extract the data from sheet1 whilst the worksheet remains hidden
Many thanks,
Paul
I currently run this macro on multiple documents in a folder. What I'd like to do is hide the worksheet - Sheet1 but still allow the macro to run.
Can anyone help with the below to allow the macro to extract the data from sheet1 whilst the worksheet remains hidden
Many thanks,
Paul
Code:
Sub LoopThroughDirectory()
Dim Filepath As String
Dim erow
Filepath = Application.ActiveWorkbook.Path
MyFile = Dir(Filepath + "\*.*")
erow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Sheet1.Rows("2:" & Format(erow)).EntireRow.ClearContents
Do While Len(MyFile) > 0
If MyFile = "ZMasterFile.xlsm" Then
Exit Sub
End If
Application.DisplayAlerts = False
Workbooks.Open (Filepath & "" & MyFile)
Range("A2:M900").Copy
ActiveWorkbook.Close
erow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
ActiveSheet.Paste Destination:=Worksheets("Raw Data").Range(Cells(erow, 1), Cells(erow, 13))
MyFile = Dir
Application.DisplayAlerts = True
Loop
End Sub
Last edited by a moderator: