Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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


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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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


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
Excel 2003 Template Help Task Pane D'Wanna Excel Discussion (Misc queries) 0 March 22nd 06 10:26 PM
Task Pane - Excel 2003 Ohkathra Excel Discussion (Misc queries) 2 August 7th 05 02:34 AM
Task Manager and Excel 2003 Mike Excel Discussion (Misc queries) 1 April 20th 05 10:40 PM
Excel 2003 File, New Task Pane Lynn Taylor Excel Programming 0 April 20th 05 05:09 PM
excel 2003 Task Pane programming Cesar Zapata[_2_] Excel Programming 0 September 13th 04 03:12 PM


All times are GMT +1. The time now is 06:30 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"