[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Go to the next record

Posted on 2014-03-14
5
Medium Priority
?
143 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 39

Accepted Solution

by:
nutsch earned 2000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

650 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