Hello All,
i am trying to copy all the worksheets from and external workbook saved in another folder into current workbook. So far, I have this:
The line in red above gets highlighted and the code does not give the intended result. How can I fix this?
Thanks
Asad
i am trying to copy all the worksheets from and external workbook saved in another folder into current workbook. So far, I have this:
Code:
Sub CopyWorksheets()
Dim sh As Worksheet, srcwb As Workbook, trgtwb As Workbook, strng As String
strng = "S:\Planning and scheduling\Rosters\Master Dispatch\Master Dispatch - " & Format(ThisWorkbook.Worksheets("Express").Range("K3").Value, "d mmmm yyyy") & ".xlsm"
[COLOR=#ff0000][B]srcwb = Workbooks(strng)[/B][/COLOR]
trgtwb = ThisWorkbook
For Each sh In Workbooks(srcwb).Worksheets
sh.Copy After:=trgtwb.Sheets(trgtwb.Sheets.Count)
Next sh
End Sub
Thanks
Asad