![]() |
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. |
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. |
All times are GMT +1. The time now is 06:42 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com