Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 360
Default .SpecialCells(xlCellTypeBlanks).EntireRow.Delete

Is there a test (and what is it?) that could be used to avoid using on
error resume next before a line like this?

..SpecialCells(xlCellTypeBlanks).count returns an error if there are no
blanks in the referred-to range.

Thanks!
Cliff Edwards

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default .SpecialCells(xlCellTypeBlanks).EntireRow.Delete

Hi Cliff

See this page
http://www.rondebruin.nl/specialcells.htm


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"ward376" wrote in message ...
Is there a test (and what is it?) that could be used to avoid using on
error resume next before a line like this?

.SpecialCells(xlCellTypeBlanks).count returns an error if there are no
blanks in the referred-to range.

Thanks!
Cliff Edwards

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default .SpecialCells(xlCellTypeBlanks).EntireRow.Delete

Nope... Ultimatelty SpecialCells(xlCellTypeBlanks) should return a range
object. If there are no blanks then the range object is nothing and so the
properties and methods will error out...

dim rng as range

on error resume next
set rng = ..SpecialCells(xlCellTypeBlanks)
on error goto 0

if not rng is nothing then
...

This type of error handling is not a bad way to go. I am a big fan of the
idea that the error handler is not there to cover up bad code. It is a tool
that should be used very judisciously. If you really wanted to you could
write a simple function that counted blank cells in and return true or false
to avoid the need for the error handler but that may be more work than it is
worth and it would certainly be extra overhead during exectution.
--
HTH...

Jim Thomlinson


"ward376" wrote:

Is there a test (and what is it?) that could be used to avoid using on
error resume next before a line like this?

..SpecialCells(xlCellTypeBlanks).count returns an error if there are no
blanks in the referred-to range.

Thanks!
Cliff Edwards


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 360
Default .SpecialCells(xlCellTypeBlanks).EntireRow.Delete

Thanks Jim, I pretty much thought that was the case.

Cliff Edwards
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default .SpecialCells(xlCellTypeBlanks).EntireRow.Delete

Maybe something like this?

Dim YourRange As Range
.....
.....
Set YourRange = Range("A1:B3")
If Application.WorksheetFunction.CountA(YourRange ) < YourRange .Count Then
' SpecialCells will not be Nothing
.....
.....

Rick


"ward376" wrote in message
...
Is there a test (and what is it?) that could be used to avoid using on
error resume next before a line like this?

.SpecialCells(xlCellTypeBlanks).count returns an error if there are no
blanks in the referred-to range.

Thanks!
Cliff Edwards


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
Work around to SpecialCells(xlCellTypeBlanks)... DanF Excel Discussion (Misc queries) 7 June 29th 08 07:36 AM
Check SpecialCells(xlCellTypeBlanks) for 0 blanks Gerry Verschuuren Excel Programming 4 September 29th 07 11:14 PM
Using SpecialCells().EntireRow.Delete on large worksheet - Very slow! Ilan[_2_] Excel Programming 6 September 15th 04 12:09 PM
Help to hide rows, SpecialCells(xlCellTypeBlanks) doesn't work... Gunnar Johansson Excel Programming 6 August 15th 04 11:54 AM
specialcells(xlcelltypeblanks) Neil[_11_] Excel Programming 5 October 9th 03 10:11 AM


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