I keep getting this error that says "Run Time Error '1004' Select Method of Range Class Failed" and if I debug it, it points to ".Range(sortRange).Select"
and if I take the "." out before the statement ".Range(sortRange).Select" I get the error "Run Time Error '1004' Sort Method of Range Class Failed." If I debug this, the VBE points to "Selection.Sort..."
There are two odd behaviors with this code. First of all, I only get this error from one particular function call, and second of all, if I am stepping through the program, the error does not show up and the program executes sucessfully. Does anyone have any ideas?
dawa1234
Code:
Public Sub Sorts()
With Worksheets(sheetName)
.Range(sortRange).Select
Selection.Sort Key1:=Range(Key),
Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom
Range("A7").Select
End With
End Sub
and if I take the "." out before the statement ".Range(sortRange).Select" I get the error "Run Time Error '1004' Sort Method of Range Class Failed." If I debug this, the VBE points to "Selection.Sort..."
There are two odd behaviors with this code. First of all, I only get this error from one particular function call, and second of all, if I am stepping through the program, the error does not show up and the program executes sucessfully. Does anyone have any ideas?
dawa1234