Hi I am trying to copy a sheet from a closed workbook to my active workbook as a new sheet at the end, but I keep getting Subscript of Range error. The active workbook is a weekly report with variable dates in the name. I need to re-use this code without specifying the name of the active workbook. Is this possible? Thanks in advance!
Here is part of my code:
Dim sourceBook As Workbook
Application.ScreenUpdating = False
Set sourceBook = Workbooks.Open("C:\Users\SESA47205\Documents\Sales Job Code List.xlsx")
sourceBook.Sheets(List).Copy After:=ActiveWorkbook.Sheets(ActiveWorkbook.Sheets.Count)
sourceBook.Close Application.ScreenUpdating = True
Columns("A:B").EntireColumn.AutoFit
Sheets(1).Select
Range("H2").Select
Application.CutCopyMode = False
Columns("O:O").Select
Selection.Cut
Columns("B:B").Select
Selection.Insert Shift:=xlToRight
Columns("A:P").Select
Columns("A:P").EntireColumn.AutoFit
Here is part of my code:
Dim sourceBook As Workbook
Application.ScreenUpdating = False
Set sourceBook = Workbooks.Open("C:\Users\SESA47205\Documents\Sales Job Code List.xlsx")
sourceBook.Sheets(List).Copy After:=ActiveWorkbook.Sheets(ActiveWorkbook.Sheets.Count)
sourceBook.Close Application.ScreenUpdating = True
Columns("A:B").EntireColumn.AutoFit
Sheets(1).Select
Range("H2").Select
Application.CutCopyMode = False
Columns("O:O").Select
Selection.Cut
Columns("B:B").Select
Selection.Insert Shift:=xlToRight
Columns("A:P").Select
Columns("A:P").EntireColumn.AutoFit