Actually i shouldn't have written activecell
i want to test if a range is something
basically im running a for loop that will test every sheet to see if it has a certain value (by running the .find method)
so if the range is found i want to continue the for loop so that it does the rest of the instruction, but if the range is not found i want it to go back to the beginning of the for loop with the next i
i keep getting errors, i dont know if i should run 1 or 2 loops, how would i tell it to go back tothe top of the loop
without using "next i" becuase then i'll have 2 next i instructions and get an error because one of those next i doesnt have a for loop with it, thanks!
oh the blasted goto statement i was warned to not touch lol, but nah the object is to also increment the counter, so by repeating the loop ill start back at increment = 1 which is where i wanted to start becuase im starting with the first worksheet, but thanks for replying
I am having trouble following what in hech your last post was supposed to mean (it IS Friday, isn't it!??!) But...
You said: "...the object is to also increment the counter, so by repeating the loop ill start back at increment = 1 which is where i wanted to start becuase im starting with the first worksheet"
Which is it? Do you want to go back to the first worksheet if the .find fails or do you want to continue on to the next sheet if the .find fails?
Or, do you want to go back to the first sheet if the .find fails and start with a new .find?
Or, am I completely missing the point (which by the way still does not address the original point of this thread. Did Skips "IsEmpty()" response help you out?)
********************
What's the best way to get the answers you need?? See FAQ222-2244 for details!
basically starting at the first worksheet, if the .find method failed then move on and test the next worksheet, but if it was succesful, then just continue on to the rest of the code in the for loop...this is how i finally did it, through recursion, if theres a better way then i would love your suggestions
Sub outtersub()
forloop 1
End Sub
Sub forloop(j As Integer)
For i = j To ThisWorkbook.Sheets.Count
Set testsheet = ThisWorkbook.Sheets(i).Range("A:A".Find(what:="Usage", lookat:=xlwhole, searchorder:=xlByColumns)
Well, in that case, using the forbidden Goto statement try somthing like this (pseudo code):
For i = 1 To ThisWorkbook.Sheets.Count
Set testsheet = ThisWorkbook.Sheets(i).Range("A:A".Find(what:="Usage", lookat:=xlwhole, searchorder:=xlByColumns)
If testsheet Is Nothing Then Goto NextSheet
Blah, Blah, Blah
NextSheet:
Next i
********************
What's the best way to get the answers you need?? See FAQ222-2244 for details!
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.