Hide rows automatically when another cell contains specific texts

Steve1208

New Member
Joined
Nov 10, 2017
Messages
28
Excel version 2013 on windows.

I have a spread sheet that I need to hide entire rows based on another cells contents.
I need two rules, based on different conditions.

Rule 1

When cell C14 contains "Select"

I need Rows 20:34 to be hidden.

When Cell C14 contains Anything other than "select"

I need Rows 20:34 to be unhidden.


Rule 2

Between the rows 40:54 I only want the next row below the current populated row to be unhidden at a time.

For example when cell C40 is populated
only rows 40:41 should be shown. Then rows 55 and below, 39 and above should be unhidden as normal, but rows 20:34, should still adhere to the 1st rule mentioned above.

When cell C41 is populated
rows 40:42 should be shown. Then rows 55 and below 39 and above should be unhidden as normal, but rows 20:34, should still adhere to the 1st rule mentioned above.

When cell C42 is populated
rows 40:43 should be shown. Then rows 55 and below 39 and above should be unhidden as normal, but rows 20:34, should still adhere to the 1st rule mentioned above.


Thank you in advance.
Please let me know if more information is required.
 
Thank you Steve059L

However the code throws up error, where I have highlighted below.
I think it is because the code does not like altering the cells that are hidden!
Is there another way to combine the two codes.

I have highlighted in bold where the debugger shows the error.

If Target.Column = 3 And Target.Row = 16 And Target.Value = "Select" Then
Range("F20:F34").Value = ""
Rows("18:34").EntireRow.Hidden = True
End If
If Target.Column = 3 And Target.Row = 16 And Target.Value <> "Select" Then
Rows("18:34").EntireRow.Hidden = False
End If

Thank again in advance.
 
Upvote 0

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
don't know why, but excel seems happy with this mod

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = 14 And Target.Column = 3 Then
If Target.Value = "Select" Then
Range("F20:F34").ClearContents

Rows("18:34").EntireRow.Hidden = True
End If
If Target.Value <> "Select" Then
Rows("18:34").EntireRow.Hidden = False
End If
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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