hiding rows based on a selection (text) in a specific cell

Blanchetdb

Board Regular
Joined
Jul 31, 2018
Messages
153
Office Version
  1. 2016
Platform
  1. Windows
I found the following coding but I would like to know to adapt it to text

Private Sub Worksheet_Change(ByVal Target As Range)
If Target = "Indeterminate" Or "Term" Or "Transfer" Or "As Required" Then Exit Sub
If Target.Address(0, 0) <> "C36" Then Exit Sub
Sheets("Sheet1").Rows("95:103").Hidden = Target.Value = 0
End Sub
<colgroup><col width="64" style="width: 48pt;" span="8"> <tbody> </tbody>

What I am looking for is where the person would select an option in Cell C36 ( example - Term) and if so, rows 95-103 would hide. There are a number of other options that would require the rows to hide as well
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Hello,

Initially .. you could test the following :

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address <> "$C$36" Then Exit Sub
  If Target = "Term" Then
    Rows("95:103").Hidden = True
  Else
    Rows("95:103").Hidden = False
  End If
End Sub

HTH
 
Upvote 0
Thank you

that worked.....awesome

if I have other options such as "Indeterminate", "Transfer", etc....How and where would I add that to the code?

I tried: If Target = "Term" Or "Indeterminate" Or "Transfer" Or "Student" Or "Term extension" Or "As required" Or "Assignment" Then...... but it didn't work
 
Upvote 0
At least ... we are heading in the right direction ...

To hard-code a long list of strings ...which should normally be located in a data validation list ...

you could test following :

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address <> "$C$36" Then Exit Sub
Dim arCases As Variant
Dim res As Variant
arCases = Array("Term", "Indeterminate", "Transfer", "Student", "Term extension", "As required", "Assignment")


  res = Application.Match(Target, arCases, 0)
  If IsError(res) Then
       Rows("95:103").Hidden = False
  Else
       Rows("95:103").Hidden = True
  End If
End Sub

Hope this will help
 
Upvote 0
Glad you could fix your problem ...

Thanks ... for your Thanks ...:)
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,751
Members
448,989
Latest member
mariah3

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