Need help with For-Next block
x will automatically increment wen the Next x line is reached. You do
not need two Next x lines to pull this off.
Do you want to skip over the ...more instructions... portion if the If
statement is true? That's the way I am interpreting it. If so, just
throw in an Else clause and remove the unneeded Next x statement.
For x = 1 To 10
If RowIsBlank(8) = True Then
Application.DisplayAlerts = False
Workbooks(TargetFile(x)).Close
Application.DisplayAlerts = True
Else
... more instructions ...
End If
Next x
Bob wrote:
I have the following code block:
For x = 1 To 10
If RowIsBlank(8) = True Then
Application.DisplayAlerts = False
Workbooks(TargetFile(x)).Close
Application.DisplayAlerts = True
Next x
End If
... more instructions ...
Next x
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.
|