Syntax error.

  • Thread starter Thread starter David McNally
  • Start date Start date
D

David McNally

how does the for each cell in range synax work? I have the
following
For Each Cell In Range("I3:I9")
If Cell.Value = "" Then
'code
Next cell
which is saying that cell is empty? thanks so much
 
It loops through the cells in the specified range one at a time and performs
the code contained within the loop structure against each cell.
 
David,

It takes each cell ion the specified range one at a time and executes the
code between the For and the next upon that cell. So first time through,
cell will refer to I3, 2nd it will refer to I4, etc.

Don't forget your End If.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
And it's not really testing for emptiness.

The cell could be empty or it could even contain a giant formula that evaluates
to "".

=if(a3=7,"",sum(x9:x22))

When a3 = 7, the .value = "".

(and a single quote (') would qualify, too.)

If you really want empty:

if isempty(cell) then
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top