Help needed with row hiding based on cell value

SpectreHUN

New Member
Joined
Aug 15, 2014
Messages
14
I want to hide certain rows based on a selection from a drop-down list. My code so far:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Cells(10, 8).Value = "Yes" Then
  'ActiveSheet.Unprotect
  Rows("11:12").Hidden = False
  'ActiveSheet.Protect , DrawingObjects:=True, Contents:=True, Scenarios:=True
Else
   'ActiveSheet.Unprotect
   Rows("11:12").Hidden = True
   'ActiveSheet.Protect , DrawingObjects:=True, Contents:=True, Scenarios:=True
End If
End Sub

My problem is that the macro runs, it hides said two rows, then when an other item is selected from the drop-down, it doesn't seem to run anymore. Any suggestions? Thanks in advance!
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
The code says that if H10 value is "Yes" then rows 11 and 12 will be visible. If cell H10 is not "Yes" but is blank or something else then the two rows will not be visible. If changing the selection in the dropdown does not change the value in cell H10, then there will be not change in the status of the two rows. Unless cell H10 holds the drop down and the drop down only has the option of "Yes" or something else, then you won't see a change until cell H10 changes.
 
Upvote 0
Yep, H10 has the drop-down. The options are Yes and No. It works! The problem was that I referenced I10 as (10, 8), whereas it is (10, 9). :D Thanks a lot!:)
 
Upvote 0

Forum statistics

Threads
1,215,302
Messages
6,124,148
Members
449,146
Latest member
el_gazar

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