![]() |
Question about a Variable being Nothing
the only problem is with declaration.
Declare variable Var1 inside sub B and your problem should be solved. Remove the public declaration of Var1. -- Pranav Vaidya VBA Developer PN, MH-India If you think my answer is useful, please rate this post as an ANSWER!! "J@Y" wrote: This is my Code: Public Var1, MyRange as Range Sub A For c = 1to 10 do Call Sub B Next c end Sub A Sub B Set Var1 = MyRange.Find("Blah", lookat:=xlPart, _ Searchorder:=xlByRows) if Not (Var1 is Nothing) then Debug.print "Var1 exist" end if end Sub B Sub B gets looped 10 times. I run into this problem where if Var1 is found in one iteration, in the next iteration, even though it doesn't refer to any Range, it is not recognized as Nothing anymore. Why is that? |
Question about a Variable being Nothing
This is a simplified version of the code. I actually use Var1 in another sub,
that's why I have it as Public. What exactly does the Public declaration do to my variable in this case? "Pranav Vaidya" wrote: the only problem is with declaration. Declare variable Var1 inside sub B and your problem should be solved. Remove the public declaration of Var1. -- Pranav Vaidya VBA Developer PN, MH-India If you think my answer is useful, please rate this post as an ANSWER!! "J@Y" wrote: This is my Code: Public Var1, MyRange as Range Sub A For c = 1to 10 do Call Sub B Next c end Sub A Sub B Set Var1 = MyRange.Find("Blah", lookat:=xlPart, _ Searchorder:=xlByRows) if Not (Var1 is Nothing) then Debug.print "Var1 exist" end if end Sub B Sub B gets looped 10 times. I run into this problem where if Var1 is found in one iteration, in the next iteration, even though it doesn't refer to any Range, it is not recognized as Nothing anymore. Why is that? |
All times are GMT +1. The time now is 06:18 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com