• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 147
  • Last Modified:

Go to the next record

In the below I want to go to the next worksheet if the condition is not met..The only way I could figure this out was by doing GOTO..What is a suggestion

For each ws in this workbook
  If ws.Range ("A2") Like "2013" Then
    GOTO Next
  else
  code line
  code line
  code line
 code line
NEXT:
Next ws
 code line
 code line
 code line
 code line

End Sub
0
upobDaPlaya
Asked:
upobDaPlaya
  • 3
  • 2
1 Solution
 
nutschCommented:
How about:

For Each ws In ActiveWorkbook.Worksheets

  If Not ws.range("A2") Like 2013 Then
    ' Code Line
    ' Code Line
    ' Code Line
    ' Code Line
  End If
  
Next ws
'
' Code Line
' Code Line
' Code Line
' Code Line

Open in new window

0
 
upobDaPlayaAuthor Commented:
If it does not meet the criteria I do not want it to execute the code after the Next WS line...if the condition is not met I need it to go to then next worksheet
0
 
nutschCommented:
That's why it says: if <b>not</b> ... Like
0
 
nutschCommented:
So the code I've put does this

For each worksheet in workbook
If not condition then
Do stuff
End if
Next worksheet

Do more stuff at the end
0
 
upobDaPlayaAuthor Commented:
Got it...did not see the NOT :)   thx
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now