PC Review


Reply
Thread Tools Rate Thread

Check SpecialCells(xlCellTypeBlanks) for >0 blanks

 
 
=?Utf-8?B?R2VycnkgVmVyc2NodXVyZW4=?=
Guest
Posts: n/a
 
      29th Sep 2007
How do I check whether the Range returned does have cells in it - otherwise
you would get an runtime error. Checking with Null, Empty, Error, etc. does
not work.
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      29th Sep 2007
dim myRng as range

set myrng = nothing
on error resume next
set myrng = somerange.cells.specialcells(xlcelltypeblanks)
on error goto 0

if myrng is nothing then
'no cells found
else
msgbox myrng.cells.count
end if




Gerry Verschuuren wrote:
>
> How do I check whether the Range returned does have cells in it - otherwise
> you would get an runtime error. Checking with Null, Empty, Error, etc. does
> not work.


--

Dave Peterson
 
Reply With Quote
 
=?Utf-8?B?R2VycnkgVmVyc2NodXVyZW4=?=
Guest
Posts: n/a
 
      29th Sep 2007
Thank you, but I was hoping I could do this without "On Error Resume Next"
but I guess that is not possible.

"Dave Peterson" wrote:

> dim myRng as range
>
> set myrng = nothing
> on error resume next
> set myrng = somerange.cells.specialcells(xlcelltypeblanks)
> on error goto 0
>
> if myrng is nothing then
> 'no cells found
> else
> msgbox myrng.cells.count
> end if
>
>
>
>
> Gerry Verschuuren wrote:
> >
> > How do I check whether the Range returned does have cells in it - otherwise
> > you would get an runtime error. Checking with Null, Empty, Error, etc. does
> > not work.

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      29th Sep 2007
I would use the first suggestion, but maybe you could use:

if somerange.cells.count = application.counta(somerange) then
'everycell has something in it
else
'at least one empty cell
end if



Gerry Verschuuren wrote:
>
> Thank you, but I was hoping I could do this without "On Error Resume Next"
> but I guess that is not possible.
>
> "Dave Peterson" wrote:
>
> > dim myRng as range
> >
> > set myrng = nothing
> > on error resume next
> > set myrng = somerange.cells.specialcells(xlcelltypeblanks)
> > on error goto 0
> >
> > if myrng is nothing then
> > 'no cells found
> > else
> > msgbox myrng.cells.count
> > end if
> >
> >
> >
> >
> > Gerry Verschuuren wrote:
> > >
> > > How do I check whether the Range returned does have cells in it - otherwise
> > > you would get an runtime error. Checking with Null, Empty, Error, etc. does
> > > not work.

> >
> > --
> >
> > Dave Peterson
> >


--

Dave Peterson
 
Reply With Quote
 
=?Utf-8?B?R2VycnkgVmVyc2NodXVyZW4=?=
Guest
Posts: n/a
 
      29th Sep 2007
That's a great one. Fantastic. I would have never thought of this solution.
Thanks a lot!

"Dave Peterson" wrote:

> I would use the first suggestion, but maybe you could use:
>
> if somerange.cells.count = application.counta(somerange) then
> 'everycell has something in it
> else
> 'at least one empty cell
> end if
>
>
>
> Gerry Verschuuren wrote:
> >
> > Thank you, but I was hoping I could do this without "On Error Resume Next"
> > but I guess that is not possible.
> >
> > "Dave Peterson" wrote:
> >
> > > dim myRng as range
> > >
> > > set myrng = nothing
> > > on error resume next
> > > set myrng = somerange.cells.specialcells(xlcelltypeblanks)
> > > on error goto 0
> > >
> > > if myrng is nothing then
> > > 'no cells found
> > > else
> > > msgbox myrng.cells.count
> > > end if
> > >
> > >
> > >
> > >
> > > Gerry Verschuuren wrote:
> > > >
> > > > How do I check whether the Range returned does have cells in it - otherwise
> > > > you would get an runtime error. Checking with Null, Empty, Error, etc. does
> > > > not work.
> > >
> > > --
> > >
> > > Dave Peterson
> > >

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
XL2002: Selection.SpecialCells(xlCellTypeBlanks).Select Trevor Williams Microsoft Excel Programming 4 1st Sep 2008 02:04 PM
Work around to SpecialCells(xlCellTypeBlanks)... DanF Microsoft Excel Misc 7 29th Jun 2008 07:36 AM
.SpecialCells(xlCellTypeBlanks).EntireRow.Delete ward376 Microsoft Excel Programming 4 29th Apr 2008 08:38 PM
SpecialCells(xlCellTypeBlanks) =?Utf-8?B?Qm9i?= Microsoft Excel Programming 1 14th Nov 2006 03:19 AM
specialcells(xlcelltypeblanks) Neil Microsoft Excel Programming 6 9th Oct 2003 10:11 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:43 AM.