I am using the below script to copy data from "Sheet1" of a multi-sheet Excel file into a master sheet of another Excel file. It's working perfectly for one sheet. Now I need to get it to run through all the sheets pasting the data into the next available row in the Master file.
Please note: all the sheets use the same password.
Please help!
Thanks,
Yohanan
Sub CopyRanges()
Dim WB1 As Workbook
Dim WB2 As Workbook
Dim LastRow As Long
Set WB1 = ActiveWorkbook
Set WB2 = Workbooks.Open(WB1.Path & "\Datafile.xls")
Sheets("Sheet1").Unprotect ("Password1")
With WB2.Sheets("Sheet1")
LastRow = .Range("B" & .Rows.Count).End(xlUp).Row
End With
WB2.Sheets("71235").Range("B6:M" & LastRow).Copy
WB1.Sheets("Output").Range("A2").PasteSpecial xlPasteValues
Sheets("Sheet1").Protect ("FTCCTOR")
WB2.Close
End Sub