Hiding Rows Based on Dropdown Selection

PC132

New Member
Joined
Sep 15, 2022
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hello,

Relatively new to the VBA function.
Working on building a checklist that automatically shows and hides specific rows based on the option selected from the dropdown.

The Dropdown options: "BOV, Off Market Flyer"

After searching a few forums below is the code:
---------------
Private Sub worksheet_change(ByVal Target As Range)
If Range("D15") = "BOV" Then
Rows("16:51").EntireRow.Hidden = False
Else
Rows("16:51").EntireRow.Hidden = True
End If

If Range("D15") = "Off Market Flyer" Then
Rows("52:54").EntireRow.Hidden = True
Else
Rows("52:54").EntireRow.Hidden = False

End If

End Sub
--------------
The macro seems to work, however, there is no change when either option is selected.

Please advice and Thank you in advance!
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Hi PC132,

Try this:

VBA Code:
Option Explicit
Private Sub worksheet_change(ByVal Target As Range)

    If Target.Address = "$D$15" Then

        With Application
            .ScreenUpdating = False
            .EnableEvents = False
        End With
    
        If Target.Value = "BOV" Then
            Rows("16:51").EntireRow.Hidden = False
        Else
            Rows("16:51").EntireRow.Hidden = True
        End If
        
        If Target.Value = "Off Market Flyer" Then
            Rows("52:54").EntireRow.Hidden = True
        Else
            Rows("52:54").EntireRow.Hidden = False
        End If
    
        With Application
            .EnableEvents = True
            .ScreenUpdating = True
        End With
        
    End If

End Sub

Regards,

Robert
 
Upvote 0
Robert,

I appreciate the quick response!

The new code works perfectly!

Much appreciated

Thanks
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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
Back
Top