Automatically hiding and unhiding rows based on a cell value

Davio

New Member
Joined
Jun 10, 2014
Messages
36
I've researched most places on the internet for a solution and have been unsuccessful. I have VERY limited knowledge regarding macros but my spreadsheet requires automatic updates. I need to figure out how to have a given row hidden if column H of the same row is equal to "N". Any help is appreciated.
 
Where did you put the code? It should go in the worksheet specific module, not a general module. You can get there quickly by right-clicking on the sheet tab and selecting View Code.
 
Upvote 0

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
It deletes the information but does not hide the row. Should both codes go in the worksheet?
 
Upvote 0
This is the autofilter code.

Rich (BB code):
Sub AutoFilter_in_Excel()
 Range("A3").AutoFilter Field:=8, Criteria1:="Y"
 End Sub
Private Sub Worksheet_Calculate()
 ' AutoFilter code here
 End Sub

I think I'll go back to the original code. I'm not a big fan or the "table" look on the summary sheet.

Rich (BB code):
Sub HURows()
Rich (BB code):
Rich (BB code):
Rich (BB code):
    BeginRow = 3<o:p></o:p>
    EndRow = 105<o:p></o:p>
    ChkCol = 8<o:p></o:p>
    For RowCnt = BeginRow ToEndRow<o:p></o:p>
        If Cells(RowCnt,ChkCol).Value = " " Then<o:p></o:p>
            Cells(RowCnt,ChkCol).EntireRow.Hidden = True<o:p></o:p>
        Else<o:p></o:p>
            Cells(RowCnt,ChkCol).EntireRow.Hidden = False<o:p></o:p>
        End If<o:p></o:p>
    Next RowCnt<o:p></o:p>
End Sub 
 
Last edited by a moderator:
Upvote 0
The original code works but it does not automatically hide the rows. Is there a "loop" code?
 
Upvote 0
Code:
Private Sub Worksheet_Calculate()
    With Range("A3")
        .AutoFilter
        .AutoFilter Field:=8, Criteria1:="Y"
    End With
End Sub

For the other code you'd need to change the criteria:

If Cells(RowCnt,ChkCol).Value = " " Then
 
Upvote 0
I've edited that portion but it still does not auto update. I eventually have to go to that page and manually run the macro for the page to be updated. Is there any code to add to it to make it run automatically or continuously?
 
Upvote 0
I just tested and this works for me:

Code:
Private Sub Worksheet_Calculate()
    Application.EnableEvents = False
        With Range("A3")
            .AutoFilter
            .AutoFilter Field:=8, Criteria1:="Y"
        End With
    Application.EnableEvents = True
End Sub
 
Upvote 0
It works great, but is there a way to have the same effect without the filter symbols visible?
 
Upvote 0

Forum statistics

Threads
1,215,575
Messages
6,125,619
Members
449,240
Latest member
lynnfromHGT

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