Solved

Skip blank cells in a For...Each Loop

Posted on 2011-02-15
3
372 Views
Last Modified: 2012-06-21
Hi Experts,

I have a For...Each loop like below:

 For Each ServiceLineValues In ServiceLineValuesRange
           If ServiceLineValues = "" Then
               MsgBox "AAAAA"
           Else
               Some other code I want to execute
           End if
 Next ServiceLineValues

Open in new window


When the cell range evaluates to true I just want to ignore this and move on to the next cell. At the moment it seems that I have to put some statement in there like Msgbox "AAAAA" just to make this work.
0
Comment
Question by:onesegun
3 Comments
 
LVL 24

Accepted Solution

by:
StephenJR earned 50 total points
Comment Utility
Like this?

 For Each ServiceLineValues In ServiceLineValuesRange
           If ServiceLineValues <> "" Then
               Some other code I want to execute
           End if
 Next ServiceLineValues
0
 

Author Closing Comment

by:onesegun
Comment Utility
Doh!!!!!
0
 
LVL 50

Expert Comment

by:Dave Brett
Comment Utility
While this is closed you can use SpecialCells to work with formulas/constants only as an inpu to the working range rather than testing cell by cell within the loop
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

728 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

11 Experts available now in Live!

Get 1:1 Help Now