Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
hide row based on cell value
i have a worksheet that i want to hide rows based on cell value.
if cell B3 is blank, then i need rows 4,5 and 6 to be hidden, B3 contains data than row 4 is visible. if cell H3 is blank, then rows 5 and 6 need to be hidden. if b3 and h3 have data, then rows 4 and 5 are visible. if cell n3 is blank then row 6 is hidden. i have the following so far: Private Sub Worksheet_change(ByVal Target As Range) Application.EnableEvents = False If Target.Address(0, 0) = "P28" Then Select Case LCase(Target.Value) Case "target": MainMenu 'this brings up a user input box and works End Select End If If Target.Address(0, 0) = "B3" Then If Range("B3") < "" Then Call hideum End If Application.EnableEvents = True End Sub < -- Sub hideum() Dim i As Long n = Cells(Rows.Count, "A").End(xlUp).Row For i = 1 To n If Cells(i, 1).Value = "XXX" Then Rows(i).Hidden = True End If Next End Sub i can run the hideum macro manually but it does not fire on it's own. any suggestions? |
#2
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
hide row based on cell value
It works ok for me.
Are you sure that it's failing--maybe you don't have any XXX in column A (upper/lower case matters in your code). jat wrote: i have a worksheet that i want to hide rows based on cell value. if cell B3 is blank, then i need rows 4,5 and 6 to be hidden, B3 contains data than row 4 is visible. if cell H3 is blank, then rows 5 and 6 need to be hidden. if b3 and h3 have data, then rows 4 and 5 are visible. if cell n3 is blank then row 6 is hidden. i have the following so far: Private Sub Worksheet_change(ByVal Target As Range) Application.EnableEvents = False If Target.Address(0, 0) = "P28" Then Select Case LCase(Target.Value) Case "target": MainMenu 'this brings up a user input box and works End Select End If If Target.Address(0, 0) = "B3" Then If Range("B3") < "" Then Call hideum End If Application.EnableEvents = True End Sub < -- Sub hideum() Dim i As Long n = Cells(Rows.Count, "A").End(xlUp).Row For i = 1 To n If Cells(i, 1).Value = "XXX" Then Rows(i).Hidden = True End If Next End Sub i can run the hideum macro manually but it does not fire on it's own. any suggestions? -- Dave Peterson |
#3
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
hide row based on cell value
probably would have helped if i had the code in the worksheet and not the
module. thankx, jat "Dave Peterson" wrote: It works ok for me. Are you sure that it's failing--maybe you don't have any XXX in column A (upper/lower case matters in your code). jat wrote: i have a worksheet that i want to hide rows based on cell value. if cell B3 is blank, then i need rows 4,5 and 6 to be hidden, B3 contains data than row 4 is visible. if cell H3 is blank, then rows 5 and 6 need to be hidden. if b3 and h3 have data, then rows 4 and 5 are visible. if cell n3 is blank then row 6 is hidden. i have the following so far: Private Sub Worksheet_change(ByVal Target As Range) Application.EnableEvents = False If Target.Address(0, 0) = "P28" Then Select Case LCase(Target.Value) Case "target": MainMenu 'this brings up a user input box and works End Select End If If Target.Address(0, 0) = "B3" Then If Range("B3") < "" Then Call hideum End If Application.EnableEvents = True End Sub < -- Sub hideum() Dim i As Long n = Cells(Rows.Count, "A").End(xlUp).Row For i = 1 To n If Cells(i, 1).Value = "XXX" Then Rows(i).Hidden = True End If Next End Sub i can run the hideum macro manually but it does not fire on it's own. any suggestions? -- Dave Peterson . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Hide Columns based on a cell value | Excel Worksheet Functions | |||
Hide row based on cell value | Excel Worksheet Functions | |||
Hide sheets based on Cell value | Excel Discussion (Misc queries) | |||
hide rows based on value in cell | Excel Discussion (Misc queries) | |||
Is there a way to HIDE a row based on a value of a cell ? | Excel Discussion (Misc queries) |