Need help with For-Next block
Bob,
There will probably be cries of outrage and spaghetti code accusations but
I'd use Goto like this
For x = 1 To 10
If RowIsBlank(8) = True Then
Application.DisplayAlerts = False
Workbooks(TargetFile(x)).Close
Application.DisplayAlerts = True
Goto 100
End If
.... more instructions ...
100
Next x
X will then increment by 1 when it reaches Next X
Mike
"Bob" wrote:
Mike,
I should have been more clear in my objective. My apologies.
If the IF-block evaluates to True, not only do I need to increment "x" by 1,
but I also need to skip the "... more instructions ..." section, too. That's
the part I'm struggling with.
Thanks again for the help.
Bob
"Mike H" wrote:
Bob,
Try
For x = 1 To 10
If RowIsBlank(8) = True Then
Application.DisplayAlerts = False
Workbooks(TargetFile(x)).Close
Application.DisplayAlerts = True
x=x+1
End If
... more instructions ...
Next x
Mike
"Bob" wrote:
I have the following code block:
but when I run the code, I receive the expected "Next without For" error
message.
I need to somehow increment "x" when the IF-block evaluates to True. Can
someone kindly tell me how to pull this off?
Thanks in advance for any help.
|