#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default isempty

very simple question, but i am stuck. i wish to see if a range is empty.
that's it.

If IsEmpty(Range("a16:a31")) Then
msgbox "all cells are empty"
else
msgbox "at least one of the cells are NOT empty"
end if

this doesn't work for some reason, even though every cell from a16:a31 are
clearly blank. it comes back as false, thus the latter statement pops up.
help. thanks, mike allen


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default isempty

isempty works on a single cell

If worksheetfunction.countA(Range("a16:a31")) = 0 Then
msgbox "all cells are empty"
else
msgbox "at least one of the cells are NOT empty"
end if

--
Regards,
Tom Ogilvy

mike allen wrote in message
...
very simple question, but i am stuck. i wish to see if a range is empty.
that's it.

If IsEmpty(Range("a16:a31")) Then
msgbox "all cells are empty"
else
msgbox "at least one of the cells are NOT empty"
end if

this doesn't work for some reason, even though every cell from a16:a31 are
clearly blank. it comes back as false, thus the latter statement pops up.
help. thanks, mike allen




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default isempty

Mike,

IsEmpty will always return False if you use a multi-cell range, regardless
of what is in those cells (or not).

Try using the worksheet COUNTA function, circa

If WorksheetFunction.CountA(Range("A1:6:A31")) = 0 Then
MsgBox "all cells are empty"
End If

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"mike allen" wrote in message
...
very simple question, but i am stuck. i wish to see if a range is empty.
that's it.

If IsEmpty(Range("a16:a31")) Then
msgbox "all cells are empty"
else
msgbox "at least one of the cells are NOT empty"
end if

this doesn't work for some reason, even though every cell from a16:a31 are
clearly blank. it comes back as false, thus the latter statement pops up.
help. thanks, mike allen




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
Loop Statement through If Not IsEmpty Then Paste into Destination Dandelo Excel Discussion (Misc queries) 7 July 15th 08 10:29 PM
Form If IsEmpty Syntax Gizmo Excel Discussion (Misc queries) 4 May 25th 08 03:50 PM
vba: isempty chick-racer[_37_] Excel Programming 3 November 17th 03 09:52 PM
Problem with IsEmpty Function Matt[_16_] Excel Programming 6 October 2nd 03 05:16 PM
IsEmpty and Is Nothinq problems Stuart[_5_] Excel Programming 12 August 29th 03 06:13 AM


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