Unhide Another Row if Range contains text Value

Newbie_Reena

New Member
Joined
Mar 31, 2016
Messages
7
Hi there! I'm new to VBA so please be gentle.

In my Excel sheet I have dropdowns that range from G20 through Z20.

I'd like to keep Row 21 hidden unless the word "Upgrade" appears anywhere in the range G20 to Z20, then i want Row 21 to be unhidden. If the user changes the dropdown and Upgrade is no longer anywhere in that range again, Row 21 goes back to hidden. Can anyone help with the VBA code? I tried to record the macro but it won't stop recording, nor will it do what I want.

Appreciate the help!
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
I've tried this but not working:

Sub ShowUpgrade(ByVal Target As Range)
'
' DefineInput Macro
'


Rows("21:21").EntireRow.Hidden = True
If Target.Row = 20 And Target.Column > 6 And Target.Value = "Upgrade" Then
Rows("21:21").EntireRow.Hidden = False
End If


End Sub
 
Upvote 0
try putting this in the worksheet's code module
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Application.Intersect(Target, Range("G20:Z10")) Is Nothing Then
        Rows(21).EntireRow.Hidden = (Application.CountIf(Range("G20:Z20"), "Upgragde") = 0)
    End If
End Sub
 
Upvote 0
Thanks! I tried that and inserted it as a new Module. It's not working. Row 21 never unhides no matter what is inputted into that range. Is there something else I should be doing?
 
Upvote 0
That is event code. I doesn't go in a new module. In the Project explorer window, double click on the sheet in question and paste that code into the window that appears.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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