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

  • Thread starter christopher.hubbard
  • 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
 
B

Bob Phillips

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)
 
C

CH

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.
 
D

Dave Peterson

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.
 
D

Don Guillett

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top