Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Syntax error.

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Syntax error.

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.

--
Regards,
Tom Ogilvy

"David McNally" wrote in message
...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Syntax error.

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)

"David McNally" wrote in message
...
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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Syntax error.

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



David McNally wrote:

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


--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Syntax Error In Date Beth Excel Discussion (Misc queries) 2 March 11th 09 01:05 PM
Syntax error Neil Pearce Excel Discussion (Misc queries) 4 November 21st 08 04:55 PM
syntax error - help Jim May Excel Discussion (Misc queries) 2 August 23rd 07 09:08 PM
Syntax Error Runtime Error '424' Object Required sjenks183 Excel Programming 1 January 23rd 04 09:25 AM
Where is my syntax error? Mike Excel Programming 2 December 16th 03 10:43 PM


All times are GMT +1. The time now is 03:23 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"