Hello:
I wrote the following code:
It works great, however, if I open another spreadsheet (excel file), I get the following error:
When I hit Debug, it goes to this line of code
I am at a loss, any ideas why I get an error when opening a sheet?
I wrote the following code:
Code:
Private Sub cmbCareerPath_Change()
With Worksheets("FindPath")
.Sort.SortFields.Clear
.Sort.SortFields.Add Key:=Range("D:D"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With .Sort
.SetRange Range("A1:E50")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End With
End Sub
It works great, however, if I open another spreadsheet (excel file), I get the following error:
Code:
Run-time error '9'
Subscript out of range
When I hit Debug, it goes to this line of code
Code:
With Worksheets("FindPath")
I am at a loss, any ideas why I get an error when opening a sheet?