Un/Hide Rows base on cell change for two different cells Un/Hiding different parts of the sheet independently.

raulmino

New Member
Joined
Apr 10, 2020
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I have a very simple code that works very well to Un/Hide rows when change the cell value of S55. BUT I need a code but works exactly the same for two portions of my sheet independently.

I mean changing the first cell un/hide some rows at the beggining and on the other side changing another cell at the end of the sheet un/hide others rows differents of the one at the beggining.


here is the code.


Private Sub Worksheet_Change(ByVal Target As Range)
Dim HideRows As Range, ViewRows As Range

If Intersect([s55], Target) Is Nothing Then Exit Sub

Select Case [s55].Value
Case Is = 0
Set HideRows = Rows("60:298")
Set ViewRows = Nothing

End Select
On Error Resume Next
HideRows.Hidden = True
ViewRows.Hidden = False
End Sub

Thanks a lot for orientation!
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Hi and welcome to MrExcel.

How about,
Change cell S55 to 0 to hide rows 60:298.
Change cell T55 to 0 to hide rows 300:598.
Change to 1 to unhide rows.

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  If Not Intersect(Target, Range("S55, T55")) Is Nothing Then
    Rows("60:298").Hidden = [S55] = 0
    Rows("300:598").Hidden = [T55] = 0
  End If
End Sub
 
Upvote 0
Cross-posted at:
Please read Mr Excel's policy on Cross-Posting in rule 13: Message Board Rules
 
Upvote 0
Sorry I am new posting a question but i really appreciated your help.

Have a great day!!!
 
Upvote 0

Forum statistics

Threads
1,214,952
Messages
6,122,454
Members
449,083
Latest member
Ava19

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