Is IsBlank() just for Excel spreadsheet and not for VBA?

HilaryF

New Member
Joined
Mar 19, 2004
Messages
30
Is it true that IsBlank() can only be used inside an Excel cell, and not in VBA code inside your workbook? If so, then would the best bet be to test the length of the value of the cell (in VBA) to determine whether it's blank or not??? Is there a list anywhere of which functions can be used only in Excel, which ones only in VBA, and which ones in both? I'm finding this very confusing.
Thanks a lot.
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
To answer one question...just test the contents of the cell in VBA...
Code:
If Range("A1") = vbNullString Then 'or it is blank
    Msgbox "Blank Cell"
End If
 
Upvote 0
Note that Tommy's first will return true if the value is blank, i.e. [A1] could hold a formula like =IF(B1=0,"","x") and if [B1] is zero, you'd get a true (which you may or may not want).
 
Upvote 0
As an equivalent for ISBLANK in VBA use

Code:
IsEmpty(RangeReference)

Regards,
Martin
 
Upvote 0
Nifty, Martin. I'd not thought of dropping a range ref inside IsEmpty() before. Testing in the Immediate window, it appears to work quite nicely with anything except a non-contiguous range.
 
Upvote 0
dropping a range ref inside IsEmpty() before
I am sorry Greg, that's a misunderstanding. IsEmpty checks just the first cell of the range, therefore:
<pre><SPAN style="color:#00007F">Sub</SPAN> TestBlanks()
<SPAN style="color:#00007F">Dim</SPAN> cl <SPAN style="color:#00007F">As</SPAN> Range
<SPAN style="color:#007F00">'</SPAN>
<SPAN style="color:#007F00">' this will work</SPAN>
<SPAN style="color:#00007F">If</SPAN> [AND(ISBLANK(A1:A10))] <SPAN style="color:#00007F">Then</SPAN> MsgBox "All Empty"
<SPAN style="color:#007F00">'</SPAN>
<SPAN style="color:#007F00">' and this will not</SPAN>
<SPAN style="color:#00007F">Set</SPAN> cl = [A1:A10]
<SPAN style="color:#00007F">If</SPAN> IsEmpty(cl) <SPAN style="color:#00007F">Then</SPAN> MsgBox "All Empty"
<SPAN style="color:#007F00">'</SPAN>
<SPAN style="color:#007F00">' and this of course works</SPAN>
<SPAN style="color:#00007F">Set</SPAN> cl = [A1]
<SPAN style="color:#00007F">If</SPAN> IsEmpty(cl) <SPAN style="color:#00007F">Then</SPAN> MsgBox cl.Address & " Empty"
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></PRE>

Sorry for the misleading contribution
:biggrin:
Best regards,
Martin
 
Upvote 0

Forum statistics

Threads
1,214,423
Messages
6,119,398
Members
448,892
Latest member
amjad24

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top