4

I am writing an IF statement that uses the IsEmpty function to determine if True or False. I tried it both on a cell with a value (e.g., PRB2039) and on a blank cell to test my code, and the result is the same.

I removed formatting, and tried it on a new worksheet. I don't know what I'm doing wrong.

Siddharth Rout
  • 147,039
  • 17
  • 206
  • 250
Cecilia Moneta
  • 41
  • 1
  • 1
  • 2

2 Answers2

8

I prefer using

If Len(Trim(Cells(i, 1).Value))=0 Then Msgbox "Empty"
Santosh
  • 12,175
  • 4
  • 41
  • 72
Siddharth Rout
  • 147,039
  • 17
  • 206
  • 250
2

As suggested by @PatricK you may consider using ISBLANK function instead of IsEmpty function. ISBLANK function Returns TRUE if the value is blank

enter image description here

Using VBA

Sub test()

    For i = 1 To 4
       MsgBox Evaluate("isblank(" & Cells(i, 1).Address & ")")
    Next

End Sub
Santosh
  • 12,175
  • 4
  • 41
  • 72