ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Hide Rows If Condition True (https://www.excelbanter.com/excel-worksheet-functions/228192-hide-rows-if-condition-true.html)

wilbursj

Hide Rows If Condition True
 
Hi
Is it possible to auto-hide a row if a condition is met. Ie If the value of
a specifc cell in that row is 0, i do not want the row to show, so either
hide it or make row hright minimal. If value changes, i would want it to
unhide or increase row height to make it visible.
Thanks

Stefi

Hide Rows If Condition True
 
You need a change event macro for that, something like this:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim ucell As Range, urows As Range
rownum = ActiveSheet.UsedRange.Rows.Count
Set urows = Range("C2:C" & ActiveSheet.UsedRange.Rows.Count) 'change
"C" to your specific column
For Each ucell In urows
ucell.EntireRow.Hidden = (ucell = 0)
Next ucell
End Sub

Regards,
Stefi


€˛wilbursj€¯ ezt Ć*rta:

Hi
Is it possible to auto-hide a row if a condition is met. Ie If the value of
a specifc cell in that row is 0, i do not want the row to show, so either
hide it or make row hright minimal. If value changes, i would want it to
unhide or increase row height to make it visible.
Thanks


Gord Dibben

Hide Rows If Condition True
 
Depends upon how the quantity is derived which event type to use.

I will assume the value is formula-derived and in Column A

Private Sub Worksheet_Calculate()
'Hide rows with formulas that return 0
Dim cell As Range
On Error GoTo endit
Application.EnableEvents = False
Application.ScreenUpdating = False
With Me.UsedRange
.Rows.Hidden = False
For Each cell In .Columns(1).SpecialCells(xlCellTypeFormulas)
If cell.Value = 0 Then cell.EntireRow.Hidden = True
Next cell
End With
endit:
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub


Gord Dibben MS Excel MVP

On Mon, 20 Apr 2009 03:25:01 -0700, wilbursj
wrote:

Hi
Is it possible to auto-hide a row if a condition is met. Ie If the value of
a specifc cell in that row is 0, i do not want the row to show, so either
hide it or make row hright minimal. If value changes, i would want it to
unhide or increase row height to make it visible.
Thanks




All times are GMT +1. The time now is 12:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com