View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Ranges vs cells with VBA

Of course, if I had bothered to check before I posted my response, I would
have seen that VBA appears to have extended the functionality of IsEmpty to
cells in a spreadsheet... IsEmpty does, in fact, work for checking if a cell
is empty or not. However, if the cell contains a formula, even if the result
of that formula is the empty string (""), IsEmpty will report False. The Len
function check I posted will report 0 (empty string) for this situation.

--
Rick (MVP - Excel)


"Rick Rothstein" wrote in message
...
IsEmpty does not exist to check if a cell is empty or not... it is used to
determine if a variable is initialize or not. You could test whether the
length of the contents of the cell are zero or not. Try this...

If Target.Column = 2 And Not IsDate(Target.Value) And Len(Target.Value)
0 Then

Your newsreader will probably word wrap the above single line of code.

--
Rick (MVP - Excel)


"Brad" wrote in message
...

If I delete each cell in a range manually - I do not get hung up in the
below "if statement". If try to "clearcontents" to the entire range - it
doesn't recognize the isEmpty(Target.value) (I believe). What options do
I
have...


If Target.Column = 2 And Not IsDate(Target.Value) And Not
IsEmpty(Target.Value) Then
MsgBox ("Inputs have to be dates")
Target.ClearContents
End If