A
ajlowndes
I have:
Dim SrcNm1 As String
Dim SrcNm2 As String
Dim WS1 As Worksheet, WS2 As Worksheet
SrcNm1 = "Sheet2"
SrcNm2 = "ClientLedgerOct31"
Set WS1 = ThisWorkbook.Worksheets(SrcNm1)
' WS1 is now successfully set as Worksheet/Sheet2
Set WS2 = ThisWorkbook.Worksheets(SrcNm2)
' This line throws up a Runtime error '9' - "Subscript out of range"
error
Why do I get the error when setting WS2 but not WS1? Is it because
there are too many letters in the sheet name?
The sheet with that name definitely exists, and the spelling is
correct etc.
Thanks
Dim SrcNm1 As String
Dim SrcNm2 As String
Dim WS1 As Worksheet, WS2 As Worksheet
SrcNm1 = "Sheet2"
SrcNm2 = "ClientLedgerOct31"
Set WS1 = ThisWorkbook.Worksheets(SrcNm1)
' WS1 is now successfully set as Worksheet/Sheet2
Set WS2 = ThisWorkbook.Worksheets(SrcNm2)
' This line throws up a Runtime error '9' - "Subscript out of range"
error
Why do I get the error when setting WS2 but not WS1? Is it because
there are too many letters in the sheet name?
The sheet with that name definitely exists, and the spelling is
correct etc.
Thanks