LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default how to have 2 drop down lists filter rows

Try...

Private Sub Worksheet_Change(ByVal Target As Range)
'This is the same for both
If Target.Cells.Count 1 Then Exit Sub
If Target.Value = "" Then Range("7:90,91:186").Rows.Hidden = False

'Store values, row refs
Const sValuesB5$ = "Dragline|Shovel|Aux|DraglineNP"
Const sRowsToHideB5$ = "91:186|7:90,142:186|7:141,163:186|7:162"
Const sRowsToUnhideB5$ = "7:90|91:141|142:162|163:186"
Const sValuesE5$ = "Unknown|Olex|Pirelli|Amercable|Prysmian|MM
Cables"
Const sRowsToHideE5$ =
"11:186|7:10,21:186|7:30,41:186|7:40,51:186|7: 50"
Const sRowsToUnhideE5$ = "7:10|11:20|21:30|31:40|41:50|51:162"

Dim aValues, aRowsToHide, aRowsToUnhide, n&

'Dtermine which cell changed
Select Case Target.Address
Case "$B$5"
aValues = Split(sValuesB5, "|")
aRowsToHide = Split(sRowsToHideB5, "|")
aRowsToUnhide = Split(sRowsToUnhideB5, "|")
GoTo HideUnhideRows

Case "$E$5"
aValues = Split(sValuesE5, "|")
aRowsToHide = Split(sRowsToHideE5, "|")
aRowsToUnhide = Split(sRowsToUnhideE5, "|")
GoTo HideUnhideRows
End Select 'Case Target.Address

Normalexit:
Exit Sub

HideUnhideRows:
Application.EnableEvents = False
For n = LBound(aValues) To UBound(aValues)
If Target.Value = aValues(n) Then
Range(aRowsToUnhide(n)).Rows.Hidden = False
Range(aRowsToHide(n)).Rows.Hidden = True
End If
Next
Application.EnableEvents = True
End Sub

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


 
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
how to have 2 drop down lists filter rows Rodog Excel Programming 0 February 14th 13 12:55 AM
Filter drop down lists anneten Excel Discussion (Misc queries) 1 March 28th 08 06:54 PM
Drop down lists that auto create and then filter the next drop down list [email protected] Excel Worksheet Functions 2 September 30th 07 11:53 AM
Multiple lists with repeated values for dependet drop down lists mcmanusb Excel Worksheet Functions 1 September 29th 06 12:13 AM
Filter arrows on drop down lists HRman Excel Discussion (Misc queries) 0 April 5th 06 10:01 AM


All times are GMT +1. The time now is 09:16 AM.

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

About Us

"It's about Microsoft Excel"