![]() |
conditional task in Excel 2003 macro
Good morning,
I ran into a problem yesterday with a macro I have used for a few months without incident. I am receiving the following run-time error: ---------------- Run-time error '1004': No cells were found. ---------------- My macro is supposed to look for blank cells in a given range, find them, and deletes the entire row(s) found to contain the blank cells. The error is now occuring because, for the first time, no blank cells exist, and I failed to consider this possibility. Here is the part of macro that fails when no blank cells are found. ----------------- 'delete rows with blank cells Columns("A:A").Select Selection.SpecialCells(xlCellTypeBlanks).Select Selection.EntireRow.Delete ----------------- How can I cope with cases where no blank cells in a given range exist and then simply bypass this part of the macro? A conditional statement, I assume. Any thoughts? As always, thanks much for any help offered. Best Regards, Joseph |
conditional task in Excel 2003 macro
one simple way
On Error resume Next Columns("A:A").SpecialCells(xlCellTypeBlanks).Sele ct If Err.Number = 0 Then Selection.EntireRow.Delete End If "Joseph Spain" wrote in message news:P5vae.402$Bb.97@okepread06... Good morning, I ran into a problem yesterday with a macro I have used for a few months without incident. I am receiving the following run-time error: ---------------- Run-time error '1004': No cells were found. ---------------- My macro is supposed to look for blank cells in a given range, find them, and deletes the entire row(s) found to contain the blank cells. The error is now occuring because, for the first time, no blank cells exist, and I failed to consider this possibility. Here is the part of macro that fails when no blank cells are found. ----------------- 'delete rows with blank cells Columns("A:A").Select Selection.SpecialCells(xlCellTypeBlanks).Select Selection.EntireRow.Delete ----------------- How can I cope with cases where no blank cells in a given range exist and then simply bypass this part of the macro? A conditional statement, I assume. Any thoughts? As always, thanks much for any help offered. Best Regards, Joseph |
conditional task in Excel 2003 macro
"Patrick Molloy" wrote:
one simple way On Error resume Next Columns("A:A").SpecialCells(xlCellTypeBlanks).Sele ct If Err.Number = 0 Then Selection.EntireRow.Delete End If Thanks much, Patrick. That works perfectly. Best regards, Joseph |
All times are GMT +1. The time now is 10:24 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com