Automatically hide/unhide rows based on cell value in excel

jag2011

New Member
Joined
Jun 28, 2011
Messages
6
Hi,
I'm new to excel VBA.
Need to do the following in a worksheet "Inlet chevron"
If cell A3 = "Combination", then hide rows 7 to 64 and unhide rows 65 to 94
If cell A3 ="Single", then hide rows 65 to 94 and unhide rows 7 to 64
Appreciate if you could type it down so that I could copy it.
Thanks in Advance.:)
 
Hi Weaver,
I'm new to excel VBA.
Need to do the following in a worksheet "BASE PLATE"
If cell C54 = "SMALL MOMENT", then hide rows 63 to 79 and unhide rows 55 to 62
If cell C54 ="LARGE MOMENT", then hide rows 55 to 62 and unhide rows 63 to 79

But unfortunately I am not even able to see the written vba code as I have written as

Option Compare Text
Private Sub BASEPLATE_Change(ByVal Target As Range)
If Target.Address = "$C$54" Then
Rows("63:79").Hidden = (Target.Value = "SMALL MOMENT")
Rows("55:62").Hidden = (Target.Value = "LARGE MOMENT")
End If
End Sub

Appreciate if you could type it down so that I could copy it.
Thanks in Advance.:smile:
 
Upvote 0

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Try this: right click the sheet tab, select View Code and paste in

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(False, False) = "A3" Then
    Select Case Target.Value
        Case "Combination": Rows("7:64").Hidden = True: Rows("65:94").Hidden = False
        Case "Single": Rows("7:64").Hidden = False: Rows("65:94").Hidden = True
    End Select
End If
End Sub

then try changing the value of A3.

Firstly, im new to the forum and vba but am trying to search without pestering people too much, however I have used the above code but wanted to have certain rows hidden with the target address empty or blank. Is anyone able to help?

this is my code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(False, False) = "E7" Then
Select Case Target.Value
Case Is <> "Mobile": Rows("8:15").Hidden = True
Case "Mobile": Rows("8:15").Hidden = False
End Select
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,283
Members
452,902
Latest member
Knuddeluff

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