Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ken Ken is offline
external usenet poster
 
Posts: 590
Default Handling a Null Cell in Macro

The following loop is part of a larger macro.

For ILoop = NumRowsF850 To 1 Step -1
If Cells(ILoop, 5) = 0 Then
Rows(ILoop).Delete
End If
Next ILoop

If I find a null cell in the loop on line two, it is evaluated as 0 and the
code branches to the third line.

I do not want to execute the third line of code if the cell is null.

How do I need to re-code line two to avoid this problem?

TIA.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Handling a Null Cell in Macro

Try adding a check for isempty:

For iloop = numrowsf850 To 1 Step -1
If Cells(iloop, 5) = 0 And Not IsEmpty(Cells(iloop, 5)) Then
Rows(iloop).Delete
End If
Next iloop

Regards,
Phil Webb


"Ken" wrote in message
...
The following loop is part of a larger macro.

For ILoop = NumRowsF850 To 1 Step -1
If Cells(ILoop, 5) = 0 Then
Rows(ILoop).Delete
End If
Next ILoop

If I find a null cell in the loop on line two, it is evaluated as 0 and

the
code branches to the third line.

I do not want to execute the third line of code if the cell is null.

How do I need to re-code line two to avoid this problem?

TIA.



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
Need a Error Handling for this Macro [email protected] Excel Discussion (Misc queries) 2 June 4th 09 07:58 AM
Failed to save table attributes of (null) into (null). Luca Brasi Excel Discussion (Misc queries) 2 February 4th 09 04:30 PM
Error handling in macro michaelberrier Excel Discussion (Misc queries) 7 May 23rd 06 09:33 PM
cell value based on null/not null in another cell spence Excel Worksheet Functions 1 February 18th 06 11:49 PM
Handling Null Field in Macro Loop Ken Excel Programming 2 October 19th 04 10:17 PM


All times are GMT +1. The time now is 01:16 PM.

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"