ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Empty cell Identified (https://www.excelbanter.com/excel-programming/343778-empty-cell-identified.html)

Brian Matlack[_17_]

Empty cell Identified
 

What code do I use to test a cell for its content? I want to know if the
cell is empty or contains text or values. Is "" produced by a formula
the same as Blank or empty?
Thanks!!


--
Brian Matlack
------------------------------------------------------------------------
Brian Matlack's Profile: http://www.excelforum.com/member.php...fo&userid=3508
View this thread: http://www.excelforum.com/showthread...hreadid=479098


Dave Peterson

Empty cell Identified
 
Nope, a cell that contains a formula that returns "" isn't empty--it has that
formula in it:

You can check:

With ActiveSheet

.Range("a1").Formula = "="""""
'then try
'.range("a1").clearcontents

MsgBox IsEmpty(.Range("a1")) & vbLf & _
CBool(.Range("a1").Value = "") & vbLf & _
CBool(Trim(.Range("a1").Value = ""))
End With

And just to muddy the waters...A cell that had a formula that returned "" and
was converted to values isn't empty, either!


Brian Matlack wrote:

What code do I use to test a cell for its content? I want to know if the
cell is empty or contains text or values. Is "" produced by a formula
the same as Blank or empty?
Thanks!!

--
Brian Matlack
------------------------------------------------------------------------
Brian Matlack's Profile: http://www.excelforum.com/member.php...fo&userid=3508
View this thread: http://www.excelforum.com/showthread...hreadid=479098


--

Dave Peterson

Tom Ogilvy

Empty cell Identified
 
if isempty(activeCell) then
' its empty


You can also look at Vartype

--
Regards,
Tom Ogilvy


"Brian Matlack"
wrote in message
news:Brian.Matlack.1xgo6g_1130249129.0561@excelfor um-nospam.com...

What code do I use to test a cell for its content? I want to know if the
cell is empty or contains text or values. Is "" produced by a formula
the same as Blank or empty?
Thanks!!


--
Brian Matlack
------------------------------------------------------------------------
Brian Matlack's Profile:

http://www.excelforum.com/member.php...fo&userid=3508
View this thread: http://www.excelforum.com/showthread...hreadid=479098





All times are GMT +1. The time now is 10:39 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com