Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Check SpecialCells(xlCellTypeBlanks) for 0 blanks

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Check SpecialCells(xlCellTypeBlanks) for 0 blanks

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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Check SpecialCells(xlCellTypeBlanks) for 0 blanks

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Check SpecialCells(xlCellTypeBlanks) for 0 blanks

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
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Check SpecialCells(xlCellTypeBlanks) for 0 blanks

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
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
IF Statement to Check for Blanks Daren Excel Worksheet Functions 5 October 15th 08 11:08 PM
Work around to SpecialCells(xlCellTypeBlanks)... DanF Excel Discussion (Misc queries) 7 June 29th 08 07:36 AM
Need Check for Blanks formula, please Carole O Excel Worksheet Functions 3 April 28th 07 11:22 AM
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 11:30 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"