![]() |
Why doesn't ths VBA Code work?
Help!
I can run this code from inside a simple Macro called subroutine with ARG replaced by a string. But when I put it in another function and call it from within my own code, I get a 424 Error, "Object required" error. And it was running until an hour ago. Anyidea what's going on? Many thanks, Mac Lingo Berkeley, CA ================================================== =========== The Code Range("A1").Select Set rng = Cells.Find(What:=ARG, After:=ActiveCell, LookIn:=xlValues, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False, SearchFormat:=False).Activate |
Why doesn't ths VBA Code work?
I think the find isn't locating the ARG value on the activesheet. this means
then that No Object (a range) has been set and so it can't activate it. try replacing you one liner with these extra lines: Set rng = Cells.Find(What:=ARG, After:=ActiveCell, LookIn:=xlValues, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False) If rng Is Nothing Then MsgBox ARG & " not found on active sheet." Else rng.Activate End If HTH Barry "Mac Lingo" wrote: Help! I can run this code from inside a simple Macro called subroutine with ARG replaced by a string. But when I put it in another function and call it from within my own code, I get a 424 Error, "Object required" error. And it was running until an hour ago. Anyidea what's going on? Many thanks, Mac Lingo Berkeley, CA ================================================== =========== The Code Range("A1").Select Set rng = Cells.Find(What:=ARG, After:=ActiveCell, LookIn:=xlValues, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False, SearchFormat:=False).Activate |
All times are GMT +1. The time now is 10:29 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com