View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Zone Zone is offline
external usenet poster
 
Posts: 269
Default Need help with an if statement

Suited, Here is another way of doing this. May not be the most
elegant, but it does tell you how many cells aren't empty. James

Sub RangeStatus()
Dim z As Range, c As Range, ct As Long
Set z = [a1:b5] 'set range as needed
ct = 0
For Each c In z
If VarType(c) < vbEmpty Then ct = ct + 1
Next c
MsgBox ct
'if ct<0 then one or more cells is not empty
End Sub



SuitedAces wrote:
I have Dim a variable as a range.

I am trying to write an IF statement based on that range being empty,
and having no success.

Any help is appreciated.


--
SuitedAces
------------------------------------------------------------------------
SuitedAces's Profile: http://www.excelforum.com/member.php...o&userid=35840
View this thread: http://www.excelforum.com/showthread...hreadid=556412