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

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
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,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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