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

  • Thread starter ragtopcaddy via AccessMonster.com
  • 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
 
J

John Nurick

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"), ...
 
R

ragtopcaddy via AccessMonster.com

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top