Hiding rows using MACROS

Brent R Janetzki

New Member
Joined
Mar 11, 2017
Messages
18
Hi, I am trying to hide rows based on a a specific value selcted in a drop down list. For example I have a drop down list of "Yes" and "No" in Cell C42. When I click on Yes I am wanting rows 45 to 47 to remain but when I click on No I want them to hidden. I've spent hours trying to work this out but I keep getting Syntax Errors and Code 438 for some reason. Talk about frustrating. Any help would be appreciated.

Thanks Brent
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
How about
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
   If Target.CountLarge > 1 Then Exit Sub
   If Target.Address(0, 0) = "C42" Then
      Rows("45:47").Hidden = Target.Value = "No"
   End If
End Sub
 
Upvote 0
Glad to help & thanks for the feedback.
 
Upvote 0
Do you mean when you change the value in C42 nothing happens?
 
Upvote 0
Is the code still in the relevant sheet module?
 
Upvote 0

Forum statistics

Threads
1,214,978
Messages
6,122,545
Members
449,089
Latest member
davidcom

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