#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Hiding rows

I need to be able to hide/unhide rows base upon a value.

If cell P5 has a value of 1, then hide rows 6,7,8 and 9
If cell P5 has a value of 2, then hide rows 7,8 and 9
If cell P5 has a value of 3, then hide rows 8 and 9
If cell P5 has a value of 4, then rows 6, 7, 8 and 9 would be visible

Would like to do this as a WorksheetChange event.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Hiding rows

Give this Change event code a try...

Private Sub Worksheet_Change(ByVal Target As Range)
Dim N As Long
If Target.Address = "$P$5" Then
N = Target.Value
If N 0 And N < 5 Then
Rows("6:9").Hidden = False
If N < 4 Then Rows((5 + N) & ":9").Hidden = True
End If
End If
End Sub

Rick (MVP - Excel)


"ordnance1" wrote in message
...
I need to be able to hide/unhide rows base upon a value.

If cell P5 has a value of 1, then hide rows 6,7,8 and 9
If cell P5 has a value of 2, then hide rows 7,8 and 9
If cell P5 has a value of 3, then hide rows 8 and 9
If cell P5 has a value of 4, then rows 6, 7, 8 and 9 would be visible

Would like to do this as a WorksheetChange event.


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
Color alternate rows when after hiding selected rows Monk[_2_] Excel Worksheet Functions 6 June 7th 08 01:36 AM
Hiding Specific Rows Based on Values in Other Rows Chris Excel Worksheet Functions 1 November 2nd 06 08:21 PM
Hiding a button when hiding rows fergusor Excel Discussion (Misc queries) 2 August 10th 06 02:31 PM
hiding Rows and buttons/comboxes, over the rows Ctech[_116_] Excel Programming 1 March 21st 06 12:38 PM
Hiding Rows if the linked rows are blank KG Excel Discussion (Misc queries) 9 May 18th 05 02:32 AM


All times are GMT +1. The time now is 08:27 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"