Two codes - Private Sub Worksheet_Change(ByVal Target As Range)

jdmchic00

New Member
Joined
May 18, 2020
Messages
6
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi!
I have a question. How can I get two codes to run on the same sheet????


Private Sub Worksheet_Change(ByVal Target As Range)
ActiveSheet.Activate
If Not Application.Intersect(Range("B4"), Range(Target.Address)) Is Nothing Then
Select Case Target.Value
Case Is = "All": Rows("14:22").EntireRow.Hidden = True
Rows("8:13").EntireRow.Hidden = False
Case Is = "Kelsey Lopez": Rows("14:22").EntireRow.Hidden = False
Rows("8:13").EntireRow.Hidden = True
End Select

Private Sub Worksheet_Change(ByVal Target As Range)
ActiveSheet.Activate
If Not Application.Intersect(Range("B52"), Range(Target.Address)) Is Nothing Then
Select Case Target.Value
Case Is = "Advanced Stage": Rows("60:62").EntireRow.Hidden = False
Rows("58:59").EntireRow.Hidden = True
Case Is = "Early Stage": Rows("58:59").EntireRow.Hidden = False
Rows("60:62").EntireRow.Hidden = True
Case Is = "Total Open Pipeline": Rows("58:62").EntireRow.Hidden = False

End Select
End If
End Sub



Thanks!
 

Some videos you may like

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
55,549
Office Version
  1. 365
Platform
  1. Windows
Hi & welcome to MrExcel.
How about
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
   If Not Application.Intersect(Range("B4"), Target) Is Nothing Then
      Select Case Target.Value
         Case "All"
            Rows("14:22").EntireRow.Hidden = True
            Rows("8:13").EntireRow.Hidden = False
         Case "Kelsey Lopez"
            Rows("14:22").EntireRow.Hidden = False
            Rows("8:13").EntireRow.Hidden = True
      End Select
   ElseIf Not Application.Intersect(Range("B52"), Target) Is Nothing Then
      Select Case Target.Value
         Case "Advanced Stage"
            Rows("60:62").EntireRow.Hidden = False
            Rows("58:59").EntireRow.Hidden = True
         Case "Early Stage"
            Rows("58:59").EntireRow.Hidden = False
            Rows("60:62").EntireRow.Hidden = True
         Case "Total Open Pipeline"
            Rows("58:62").EntireRow.Hidden = False
      End Select
   End If
End Sub
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
55,549
Office Version
  1. 365
Platform
  1. Windows
You're welcome.
 

Watch MrExcel Video

Forum statistics

Threads
1,127,595
Messages
5,625,697
Members
416,128
Latest member
WarJamAnd

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top