Solved

Skip blank cells in a For...Each Loop

Posted on 2011-02-15
3
382 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
[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 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
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…
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.

752 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