Hide/unhide rows

abugharibh

New Member
Joined
May 16, 2019
Messages
10
Hello
trying to unhide/hide rows based on cell value. the cell is : N4, and it contains years from 2018-2020
im using this code:

If Target.Address(False, False) = "N4" Then
Select Case Target.Value
Case "2018: Rows("7:57").Hidden = False
Case "2019": Rows("60:110").Hidden = False
Case "2020": Rows("113:163").Hidden = False

End Select
End If
End Sub
it does unhide the rows i want , but i dont know how to make it hide all other rows. e.g. when N4=2019 , i want to unhide rows 60:110 but at the same time hide rows 7:57 and 113:163

Thanks in advance
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Why not add a line of code to hide ALL those lines first (before your "Select Case..." line), then the rest of your code will just unhide the correct section, based on the selection?
 
Upvote 0
Solution
Why not add a line of code to hide ALL those lines first (before your "Select Case..." line), then the rest of your code will just unhide the correct section, based on the selection?
Thanks alot. I don’t know a line of code that hides those lines though. Any example/ideas will be very helpful.
 
Upvote 0
You are welcome.
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,893
Members
449,097
Latest member
dbomb1414

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