method 'range' of object'_global' failed on XL sort

  • Thread starter Thread starter ragtopcaddy via AccessMonster.com
  • Start date Start date
R

ragtopcaddy via AccessMonster.com

I am getting the error msg "method 'range' of object'_global' failed "
sporadically in my code. I read elsewhere not to use "With ObjXL", but
there's no explanation of why.

I get it off and on with this line:

With objXL
(lots of other code...)
.ActiveSheet.Range("A1:AO" & iRow).Select
'Here's where I get the error:
.Selection.Sort Key1:=Range("AK2"), Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:
=xlTopToBottom, _
DataOption1:=xlSortNormal
End With

I have also seen another strange error with something like "RPL" in it's text
at the same point in my code.

Thanks,

Bill R

--
Bill Reed

"If you can't laugh at yourself, laugh at somebody else"

Message posted via AccessMonster.com
 
You need to qualify the call to the Range method with the object on
which you want to invoke the method. Maybe
.Selection.Sort Key1:= .ActiveSheet.Range("AK2"), ...
 
John,

Thanks for the suggestion. It sounds like that might be the problem. I'll try
it this afternoon.

Thanks,

Bill Reed

John said:
You need to qualify the call to the Range method with the object on
which you want to invoke the method. Maybe
.Selection.Sort Key1:= .ActiveSheet.Range("AK2"), ...
I am getting the error msg "method 'range' of object'_global' failed "
sporadically in my code. I read elsewhere not to use "With ObjXL", but
[quoted text clipped - 18 lines]

--
Bill Reed

"If you can't laugh at yourself, laugh at somebody else"

Message posted via AccessMonster.com
 
Back
Top