VBA Return True if Value of cell is Blank (Null) not Empty

brickhaus

New Member
Joined
Mar 30, 2018
Messages
9
Hi All. I'm pretty much a novice - this seems like it should be easy but haven't been able to figure it out...

Here's what I'm working on - it hides rows based on value of column 3

Code:
Sub HURowsMaterialOrder()    BeginRow = 2
    EndRow = 101
    ChkCol = 3


    For RowCnt = BeginRow To EndRow
        If Cells(RowCnt, ChkCol).[COLOR=#ff0000]Value = "" [/COLOR]Then
            Cells(RowCnt, ChkCol).EntireRow.Hidden = True
        Else
            Cells(RowCnt, ChkCol).EntireRow.Hidden = False
        End If
    Next RowCnt
End Sub

It works fine if cell is "empty" - no value, but doesn't work if it's "blank" - contains formula with null product "". I need it to answer True to Null...

Any help would be much appreciated...

Thanks!
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
It should work for either so check you arent using " " with a space for example.
 
Upvote 0
Thank you for responding.

No there isn't a space... here's an example of what's in the cell that's being checked:

=IFERROR(VLOOKUP(B4,'Costing Reference'!$B$1:$K$111,7, FALSE),"")

the VLOOKUP is returning a blank cell and therefore the IFERROR should be returning a ""

If I delete the formula (ie make it empty) then the macro works and hides the row...
 
Upvote 0
You arent invoking the IFERROR if the VLOOKUP is finding its lookup value. See what this produces if you put it in a cell:

=VLOOKUP(B4,'Costing Reference'!$B$1:$K$111,7, FALSE)

If its referencing a blank cell it should produce 0 if the lookup value is being found. If the formula produces a blank then theres probably a space in that cell.
 
Upvote 0
The VLOOKUP doesn't find a value there most of the time and usually this generates an error code (#VALUE!, etc) that's why I make a habit of using IFERROR... the only time the cell produces a response is when it finds its lookup value.

I've tried just with VLOOKUP and the same thing continues to happen. When there's a value in the 7th column it finds it, although strangely it's not coming up with any type of error when the cell is blank...

I've also tried using INDEX(MATCH) and it produces the same result...
 
Upvote 0
The code you posted in your OP should be hiding rows where the col C value is the null string. That includes both truly blank cells and cells with a formula that returns "" (the null string). It works fine for me. In an empty cell if you enter =LEN(C3) where C3 is replaced by a col C cell that has a formula that you believe is returning "", what do you get?
 
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,678
Members
449,116
Latest member
HypnoFant

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