Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
jat jat is offline
external usenet poster
 
Posts: 33
Default 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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 35,218
Default 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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
jat jat is offline
external usenet poster
 
Posts: 33
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hide Columns based on a cell value Tami Excel Worksheet Functions 10 July 16th 09 06:31 PM
Hide row based on cell value Munchkin Excel Worksheet Functions 2 June 25th 09 02:21 AM
Hide sheets based on Cell value Mike Milmoe Excel Discussion (Misc queries) 4 January 16th 07 05:57 AM
hide rows based on value in cell dummster Excel Discussion (Misc queries) 0 February 15th 06 03:27 PM
Is there a way to HIDE a row based on a value of a cell ? Reddiance Excel Discussion (Misc queries) 4 January 26th 05 02:57 AM


All times are GMT +1. The time now is 03:55 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"