VBA check if cell is blank and automatically hide that row

Janvon13

New Member
Joined
May 31, 2019
Messages
1
Hi,

This is my first post but I have found many answers on this website before but struggling to find something on the following problem:

I am currently trying to write a VBA code which would automatically hide a whole row when this formula displays a blank =IFNA(VLOOKUP(A10,”Sheet 10”!A:C,10,FALSE)," ") in that rows cell.

The cells ranges that contain this formula are B10:B15 and B20:B25 in Sheet 5; and B10:B15 B25:B30 in Sheet 6.

To give more context, I use a data validation, drop down menu method to select a case that I want to view and some cases contain more rows of information than others, the cases that contain no information in the mentioned rows above I want to be able to hide automatically if they are blank

Any help would be much appreciated.

Thank you
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Welcome to the forum.

Try this

Code:
Sub test()
    Dim c As Range
    For Each c In Sheets("Sheet5").Range("B10:B15,B20:B25")
        If c.Value = "" Then
            c.EntireRow.Hidden = True
        Else
            c.EntireRow.Hidden = True
        End If
    Next
    For Each c In Sheets("Sheet6").Range("B10:B15,B25:B30")
        If c.Value = "" Then
            c.EntireRow.Hidden = True
        Else
            c.EntireRow.Hidden = True
        End If
    Next
End Sub
 
Last edited:
Upvote 0
@DanteAmor
Think there's a couple of typos, everything says true & nothing false.
 
Upvote 0
@DanteAmor
Think there's a couple of typos, everything says true & nothing false.

It's true, I forgot to change the second line.
This is correct.

Code:
Sub test()
    Dim c As Range
    For Each c In Sheets("Sheet5").Range("B10:B15,B20:B25")
        If c.Value = "" Then
            c.EntireRow.Hidden = True
        Else
            c.EntireRow.Hidden = [COLOR=#0000ff]False[/COLOR]
        End If
    Next
    For Each c In Sheets("Sheet6").Range("B10:B15,B25:B30")
        If c.Value = "" Then
            c.EntireRow.Hidden = True
        Else
            c.EntireRow.Hidden = [COLOR=#0000ff]False[/COLOR]
        End If
    Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,875
Messages
6,122,040
Members
449,063
Latest member
ak94

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