Solved

Go to the next record

Posted on 2014-03-14
5
128 Views
Last Modified: 2014-03-15
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
Comment
Question by:upobDaPlaya
  • 3
  • 2
5 Comments
 
LVL 39

Accepted Solution

by:
nutsch earned 500 total points
ID: 39930862
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
 

Author Comment

by:upobDaPlaya
ID: 39930868
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
 
LVL 39

Expert Comment

by:nutsch
ID: 39930873
That's why it says: if <b>not</b> ... Like
0
 
LVL 39

Expert Comment

by:nutsch
ID: 39930876
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
 

Author Comment

by:upobDaPlaya
ID: 39930878
Got it...did not see the NOT :)   thx
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Drop Down List with Unique/Distinct Values (enhancing the Combo-Box with a few steps and a little code) David miller (dlmille) Intro Have you ever created a data validation list from a database field or spreadsheet column (e.g., Zip Codes or Co…
Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now