VBA Code To hide rows based on a cell value.

deanlongstaff

New Member
Joined
Jan 27, 2019
Messages
4
I have a combo box linked to cell "AE1". When the value in ("AE1") is "Yes", i need rows 40:41 to hide. And when it shows "No" in the box, i need rows 40:41 to be visible again. It needs to work in real time. Can anyone help me with the VBA code for this? Thanks
 

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,)
this style of question has been asked and answered often, have a search of the forum, you will find many examples
 
Upvote 0
as @mole999 says, there are lots of similar examples if you search the forum

Are you using a Forms Control ComboBox (ie NOT active-x)?
Does selecting "yes" in the combobox return value 1 in cell AE1?

Try
Code:
Sub DropDown1_Change()
    With ActiveSheet
        .Rows("40:41").EntireRow.Hidden = (.Range("AE1").Value = 1)
    End With
End Sub
 
Last edited:
Upvote 0
If your using a Activex Combobox I know of no way to link it
But you would use this script

Code:
Private Sub ComboBox1_Change()
'Modified  1/28/2019  6:24:46 AM  EST
If ComboBox1.Value = "Yes" Then Rows("40:41").Hidden = True
If ComboBox1.Value = "No" Then Rows("40:41").Hidden = False
End Sub
 
Upvote 0
Well I see now how you linked the Combobox but not sure why you think you need to do that.
That's not needed
 
Upvote 0

Forum statistics

Threads
1,216,028
Messages
6,128,393
Members
449,446
Latest member
CodeCybear

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