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.
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Welcome to the Board!

How is column H changing? Via formula or manually?

You can record applying AutoFilter to column H and call that from either a Change event or Calculate event depending on how the change is happening.
 
Upvote 0
The H column is reading from my main sheet where I input my data and the second sheet (Quick View) is my summary sheet. I'm trying to have the summary sheet hide the corresponding rows if column H is equal to "N". I also want to have the updates automatic instead of starting the macro each time.
 
Upvote 0
I've found this code and it seems to work, except that I cannot get it to run continuously.
Sub HURows()
BeginRow = 3
EndRow = 105
ChkCol = 8
For RowCnt = BeginRow To EndRow
If Cells(RowCnt, ChkCol).Value = " " Then
Cells(RowCnt, ChkCol).EntireRow.Hidden = True
Else
Cells(RowCnt, ChkCol).EntireRow.Hidden = False
End If
Next RowCnt
End Sub
 
Upvote 0
I've found this code and it seems to work, except that I cannot get it to run continuously. Sub HURows()
BeginRow = 3
EndRow = 105
ChkCol = 8
For RowCnt = BeginRow To EndRow
If Cells(RowCnt, ChkCol).Value = " " Then
Cells(RowCnt, ChkCol).EntireRow.Hidden = True
Else
Cells(RowCnt, ChkCol).EntireRow.Hidden = False
End If
Next RowCnt
End Sub

That code uses a loop, which is really inefficient. You're much better off using the AutoFilter method.
 
Upvote 0
The auto filter is definitely more user friendly. Is there anything extra needed for the macro to run or loop continuously? My end result is that once I make a change on the main sheet to have the summary sheet automatically updated.
 
Upvote 0
Nope, just put it in the sheet's Calculate event.

Private Sub Worksheet_Calculate()
' AutoFilter code here
End Sub
 
Upvote 0
I've copied and pasted but I still have to manually run the macro for the changes to take effect. What am I doing wrong?
 
Upvote 0

Forum statistics

Threads
1,213,487
Messages
6,113,941
Members
448,534
Latest member
benefuexx

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