EXCEL VBA to autohide rows with no value in a certain column

buttercup116

New Member
Joined
Jan 10, 2013
Messages
9
I have an intense worksheet filled with IF formulas.

most of them are set up like this: =IF(ISBLANK(A1),"",A1)
A cell with "" as the answer to the IF statement returns no value.

So, here is my dilema...

When a cell in column D, specifically in the range of D67:D350, returns blank ("") or no value, I would like the row to hide.
This is the nonfunctional code I have in the worksheet:

<code>
Private Sub Worksheet_Change(ByVal Target As Range)
Dim c As Range
For Each c In Range("D97:D350")
If IsBLANK(c.Value) Then
c.EntireRow.Hidden = True
Else
c.EntireRow.Hidden = False
End If
Next c
End Sub
</code>


Right now "" is hilighted in yellow as an error. I would appreciate any and all help.
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Oops, I meant:

Right now "Private Sub Worksheet_Change(ByVal Target As Range)" is hilighted in yellow as an error. I would appreciate any and all help.
 
Upvote 0
Hi and welcome to the Noard
try
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim c As Range
    For Each c In Range("D97:D350")
        If c.Value = "" Then
            c.EntireRow.Hidden = True
            Else
            c.EntireRow.Hidden = False
        End If
    Next c
End Sub
 
Upvote 0
Hi and welcome to the Noard
try
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim c As Range
    For Each c In Range("D97:D350")
        If c.Value = "" Then
            c.EntireRow.Hidden = True
            Else
            c.EntireRow.Hidden = False
        End If
    Next c
End Sub

Thank you, that worked very well!!
 
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,369
Members
449,080
Latest member
Armadillos

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