I am getting a (subscript out of range) error with the following code and despite my best efforts, cannot seem to work out what is causing it.
I am wanting to ensure I reference the actual Sheet Number of the workbook so that if someone changes the sheetname, the code will not bug out.
Dim wkb As Workbook
Dim wks1 As Worksheet
Dim wks2 As Worksheet
Dim rng As Range
Set wkb = Application.ThisWorkbook
'turn off updates to speed up code execution ->
.ScreenUpdating = False
.EnableEvents = False
.Calculation = xlCalculationManual
.DisplayAlerts = False
Set wks1 = wkb.Sheets("Sheet9")
Set wks2 = wkb.Sheets(Sheet17)