Hide Rows in one W/S Based on a cell value in Another W/S

  • Thread starter Thread starter christopher.hubbard
  • Start date Start date
C

christopher.hubbard

Hide Rows in one W/S Based on a cell value in Another W/S

I have the following code in an excel spreadsheet (see below). The
code correctly hides the rows when C98 in one worksheet = "Dog" but
when C98 does not = "Dog" it does not unhide the cells on Sheet Blue.
Why?

Select Case UCase(Range("C98").Value)
Case "Dog"
Sheets("Blue").Rows("94:113").EntireRow.Hidden = False
Case Else
Sheets("Blue").Rows("94:113").EntireRow.Hidden = True
End Select
 
You upshift the value, but test against proper case, as well as having the
TRUE/FALSE revresed.. Shouldn't it be

Select Case UCase(Range("C98").Value)
Case "DOG"
Sheets("Blue").Rows("94:113").EntireRow.Hidden = True
Case Else
Sheets("Blue").Rows("94:113").EntireRow.Hidden = False
End Select


--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)
 
Bob said:
You upshift the value, but test against proper case, as well as having the
TRUE/FALSE revresed.. Shouldn't it be

Select Case UCase(Range("C98").Value)
Case "DOG"
Sheets("Blue").Rows("94:113").EntireRow.Hidden = True
Case Else
Sheets("Blue").Rows("94:113").EntireRow.Hidden = False
End Select


--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)

Thanks for the help.

For some reason it worked when I capitalized "DOG" rather than using
"Dog"

The False and True weren't mixed up, thats they way I wanted it to
function.
 
That's why Bob capitalized it.
Select Case UCase(Range("C98").Value)
Case "DOG"

If you're going to use UCase(), then you'll want all your comparisons against
upper case strings--otherwise, you'll never get a match.
 
I'm sure that Bob meant to do that. The ucase( forces excel to compare
apples and apples regardless of how the user typed it. dog Dog dOG, etc.
Select Case UCase(Range("C98").Value)
 
Back
Top