E
ExcelMonkey
I have a bunch of nested For Loops. They loop through sheets then loop
through certain search routines, and then loop through cells. Within the
third For Loop I have a counter called SummarySheetRowCounter. When this
reaches 65536, I want to be able to stop what is happening in the third loop,
and then advance the Second Loop (SearchType). How do I exit the third loop
without ending the entire sub routine? Note that I could have preceeded the
third loop with an IF statement saying if SummarySheetRowCounter <> 65536
Then do what you do in third loop. But this will not work as the counter
needs to increment within this third loop. An If statement outside of this
third loop will not have visiblity to the counter value to make the If work.
What can I do to do this properly?
For Each Sheet in Worksheets
For SearchType = 1 to 10
For Each cell in Cells
'Code that prints results in rows of sheet
SummarySheetRowCounter =
Application.WorksheetFunction.CountBlank(Worksheets(AuditShtName).Range("B2:B65536"))
NExt
Next
Next
Thanks
through certain search routines, and then loop through cells. Within the
third For Loop I have a counter called SummarySheetRowCounter. When this
reaches 65536, I want to be able to stop what is happening in the third loop,
and then advance the Second Loop (SearchType). How do I exit the third loop
without ending the entire sub routine? Note that I could have preceeded the
third loop with an IF statement saying if SummarySheetRowCounter <> 65536
Then do what you do in third loop. But this will not work as the counter
needs to increment within this third loop. An If statement outside of this
third loop will not have visiblity to the counter value to make the If work.
What can I do to do this properly?
For Each Sheet in Worksheets
For SearchType = 1 to 10
For Each cell in Cells
'Code that prints results in rows of sheet
SummarySheetRowCounter =
Application.WorksheetFunction.CountBlank(Worksheets(AuditShtName).Range("B2:B65536"))
NExt
Next
Next
Thanks