isempty function

  • Thread starter Thread starter keyur
  • Start date Start date
K

keyur

hi

in my macro isempty always returns True irrespective of
whether the cell is empty or not. ne1 have ne idea why
this might be happening.

thanks
 
Shouldn't do. Show us some sample code so that we can see what you are
doing.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
i think i see y. Isempty checks whether variable has been
initialized. i am writing an if statememt so if a cell is
empty do this or else exit. so wht will be my boolean
expression?
thanks
 
ok so i was wrong that i found the reason. isempty does
checks for empty cells right???

here's my code. interestingly if i put D2 in quotation it
always returns False. thanks

Sub ClearSPN()

If IsEmpty(D2) Then
'MsgBox "True"
Exit Sub
Else
'MsgBox "False"
Range("D2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Delete Shift:=xlUp
Columns("D:D").Delete
ActiveSheet.Shapes("Clear").Delete
Range("A1").Select
End If

End Sub
 
IsEmpty is used to determine if a variable has been
initialized. To test if a cell contains a value, try one
of these:

'Where A1 is the cell
Len(ActiveSheet.Range("A1").value) = 0

ActiveSheet.Range("A1").value = ""

tod
 
Your code is treating D2 as a variable, which as you haven't populated, it
is empty. If you put D2 in quotes, it is testing the string D2 for being
empty, which it never is (it is D2).

What you want is

If IsEmpty(Range("D2").Value) Then


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
that makes hell lot of sense now
thanks

-----Original Message-----
Your code is treating D2 as a variable, which as you haven't populated, it
is empty. If you put D2 in quotes, it is testing the string D2 for being
empty, which it never is (it is D2).

What you want is

If IsEmpty(Range("D2").Value) Then


--

HTH

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




.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top