further to this query, can you have two or more worksheet_change events on the one page? if so, what is the naming syntax for the events fter the initial one?
Private Sub Worksheet_Change_one(ByVal Target As Range)
Dim myRows As String
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("a77")) Is Nothing Then
With Me
.Rows("78:95").RowHeight = 0
Select Case Target.Value
Case "QRail": myRows = "78:95"
Case "Bribie": myRows = "79:79"
Case "BrisbaneTransport": myRows = "80:80"
Case "BCCFerries": myRows = "81:81"
Case "Buslink": myRows = "82:82"
Case "Caboolture": myRows = "83:83"
Case "Clarks": myRows = "84:84"
Case "Hornibrook": myRows = "85:85"
Case "Kangaroo": myRows = "86:86"
Case "MtGravatt": myRows = "87:87"
Case "National": myRows = "88:88"
Case "ParkRidge": myRows = "89:89"
Case "Sunbus": myRows = "90:90"
Case "Thompson": myRows = "91:91"
Case "Westside": myRows = "92:92"
Case "SouthernCross": myRows = "93:93"
Case "Surfside": myRows = "94:94"
Case "BBL": myRows = "95:95"
Case "AllOperators": myRows = "78:95"
End Select
If Len(myRows) Then .Rows(myRows).AutoFit
End With
ElseIf Not Intersect(Target,Range("NewRange")) Is Nothing Then
'New code here
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim myRows As String
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("b172")) Is Nothing Then
With Me
.Rows("187:2940").RowHeight = 0
Select Case Target.Value
Case "QRail": myRows = "187:339"
Case "Bribie": myRows = "340:492"
Case "BrisbaneTransport": myRows = "493:645"
Case "BCCFerries": myRows = "646:798"
Case "Buslink": myRows = "799:951"
Case "Caboolture": myRows = "952:1104"
Case "Clarks": myRows = "1105:1257"
Case "Hornibrook": myRows = "1258:1410"
Case "Kangaroo": myRows = "1411:1563"
Case "MtGravatt": myRows = "1564:1716"
Case "National": myRows = "1717:1869"
Case "ParkRidge": myRows = "1870:2022"
Case "Sunbus": myRows = "2023:2175"
Case "Thompson": myRows = "2176:2328"
Case "Westside": myRows = "2329:2481"
Case "SouthernCross": myRows = "2482:2634"
Case "Surfside": myRows = "2635:2787"
Case "BBL": myRows = "2788:2938"
Case "AllOperators": myRows = "187:2940"
End Select
If Len(myRows) Then .Rows(myRows).AutoFit
End With
Else If Not Intersect(Target, Range("a77")) Is Nothing Then
With Me
.Rows("78:95").RowHeight = 0
Select Case Target.Value
Case "QRail": myRows = "78:78"
Case "Bribie": myRows = "79:79"
Case "BrisbaneTransport": myRows = "80:80"
Case "BCCFerries": myRows = "81:81"
Case "Buslink": myRows = "82:82"
Case "Caboolture": myRows = "83:83"
Case "Clarks": myRows = "84:84"
Case "Hornibrook": myRows = "85:85"
Case "Kangaroo": myRows = "86:86"
Case "MtGravatt": myRows = "87:87"
Case "National": myRows = "88:88"
Case "ParkRidge": myRows = "89:89"
Case "Sunbus": myRows = "90:90"
Case "Thompson": myRows = "91:91"
Case "Westside": myRows = "92:92"
Case "SouthernCross": myRows = "93:93"
Case "Surfside": myRows = "94:94"
Case "BBL": myRows = "95:95"
Case "AllOperators": myRows = "78:95"
End Select
If Len(myRows) Then .Rows(myRows).AutoFit
End With
End If
End Sub
I forgot to mention that the two intersect cells A77 and B172 are totally mutually exclusive. will this matter?
nevermind. it works well. i don't really understand the difference between the "If intersect " and the "If NOT intersect" that you use in this latest version. can you point me to some good reading material?