How to Hide and unhide rows by input provided in terms of Y/N ?

trustmeasfrnd

New Member
Joined
Oct 19, 2008
Messages
32
Hi,
how to Hide or unhide specific rows by inputting Y = Yes to Hide N = No to unhide.
like in excel sheet if in B5 input is "Y" it hide row 18 to row 25 and when i input "N" it unhide those rows.
does it need to use VBA or it can be done without VBA?

thanks and regards,
Abhisekh
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
It needs VBA. Right click the sheet name and select "View Code" then paste the following:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)


If Application.Intersect(Target, Range("B5")) Is Nothing Then Exit Sub
Range("18:25").EntireRow.Hidden = Range("B5").Value = "Y"


End Sub

WBD
 
Upvote 0
Solution
WBD,
wow Thanks that worked.Can you explain what this code means so i ve better understanding.
thanks and regards,
Abhisekh
 
Upvote 0
Code:
If Application.Intersect(Target, Range("B5")) Is Nothing Then Exit Sub

The line above checks whether the range that has changed includes your cell (B5). If not, it quits out.

Code:
Range("18:25").EntireRow.Hidden = Range("B5").Value = "Y"

This line sets the Hidden property of the rows. This can be True or False. This part:

Code:
Range("B5").Value = "Y"

Returns True if you put a Y in B5 (so it hides the rows) or False for anything else (so it unhides the rows).

WBD
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,286
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