Solved

Skip blank cells in a For...Each Loop

Posted on 2011-02-15
3
378 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
ID: 34897507
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
ID: 34897656
Doh!!!!!
0
 
LVL 50

Expert Comment

by:Dave Brett
ID: 34901733
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
randomize data from excell cell 15 47
Formula in  Excel or vba to transfer values from Column X to Y 5 32
Excel VBA 30 43
vba to flip column 14 21
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

828 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