Hi
I am trying to move sheets to a new workbook but I am having no luck
Sub MoveSheets()
Const ShDir As String = "C:\Users\daves\Desktop\Office\Excel\Charts Singles\"
Dim thisWB As Workbook: Set thisWB = thisWorkbook
Dim theYearBook As Workbook: Set theYearBook = Workbooks.Open(ShDir & "2020.xlsx")
Yearbkshts = theYearBook.Sheets.Count
With thisWB
.Activate
For Each sh In Sheets
sh.Activate
ActiveSheet.Move After:=Workbooks(theYearBook).Sheets(Yearbkshts) ' Error on this line
Next sh
End With
End Sub
Thank you
I am trying to move sheets to a new workbook but I am having no luck
Sub MoveSheets()
Const ShDir As String = "C:\Users\daves\Desktop\Office\Excel\Charts Singles\"
Dim thisWB As Workbook: Set thisWB = thisWorkbook
Dim theYearBook As Workbook: Set theYearBook = Workbooks.Open(ShDir & "2020.xlsx")
Yearbkshts = theYearBook.Sheets.Count
With thisWB
.Activate
For Each sh In Sheets
sh.Activate
ActiveSheet.Move After:=Workbooks(theYearBook).Sheets(Yearbkshts) ' Error on this line
Next sh
End With
End Sub
Thank you