Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 84
Default Hide/Show Rows based on Cell Value with Data Validation

Hello, I've been searching through these forums since last night, but just
can't figure this out. I have a cell with data validation, and 2 values
"Migration" and "Transition".

If the cell (B15) is blank, I want all the rows to be hidden (16:32)
If the cell (B15) equals Migration, I want to hide rows 24:32
If the cell (B15) equals Transition, I want to hide rows 17:24

Below is what I have... but I must be missing something.

----------------
Private Sub Worksheet_Change(ByVal Target As Range)

Application.ScreenUpdating = False
If Range("B15").Value = "" Then
Range(Rows(16), Rows(32)).EntireRow.Hidden = True
ElseIf Range("B15").Value = "Migration" Then
Range(Rows(17), Rows(24)).EntireRow.Hidden = False:
Range(Rows(25), Rows(32)).EntireRow.Hidden = True
ElseIf Range("B15").Value = "Transition" Then
Range(Rows(17), Rows(24)).EntireRow.Hidden = True:
Range(Rows(25), Rows(32)).EntireRow.Hidden = False
End If
Application.ScreenUpdating = True
End Sub
----------------

Any help is appreciated - THANKS!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Hide/Show Rows based on Cell Value with Data Validation

This should do it

Private Sub Worksheet_Change(ByVal Target As Range)

Application.ScreenUpdating = False
Me.Rows("16:32").Hidden = False
If Target.Value = "" Then
Me.Rows("16:32").Hidden = True
ElseIf Target.Value = "Migration" Then
Me.Rows("24:32").Hidden = True
ElseIf Target.Value = "Transition" Then
Me.Rows("17:24").Hidden = True
End If
Application.ScreenUpdating = True
End Sub

You did put the code in the worksheet code module?

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Shelly" wrote in message
...
Hello, I've been searching through these forums since last night, but just
can't figure this out. I have a cell with data validation, and 2 values
"Migration" and "Transition".

If the cell (B15) is blank, I want all the rows to be hidden (16:32)
If the cell (B15) equals Migration, I want to hide rows 24:32
If the cell (B15) equals Transition, I want to hide rows 17:24

Below is what I have... but I must be missing something.

----------------
Private Sub Worksheet_Change(ByVal Target As Range)

Application.ScreenUpdating = False
If Range("B15").Value = "" Then
Range(Rows(16), Rows(32)).EntireRow.Hidden = True
ElseIf Range("B15").Value = "Migration" Then
Range(Rows(17), Rows(24)).EntireRow.Hidden = False:
Range(Rows(25), Rows(32)).EntireRow.Hidden = True
ElseIf Range("B15").Value = "Transition" Then
Range(Rows(17), Rows(24)).EntireRow.Hidden = True:
Range(Rows(25), Rows(32)).EntireRow.Hidden = False
End If
Application.ScreenUpdating = True
End Sub
----------------

Any help is appreciated - THANKS!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Hide/Show Rows based on Cell Value with Data Validation


"Shelly" skrev i en meddelelse
...
Hello, I've been searching through these forums since last night, but just
can't figure this out. I have a cell with data validation, and 2 values
"Migration" and "Transition".

If the cell (B15) is blank, I want all the rows to be hidden (16:32)
If the cell (B15) equals Migration, I want to hide rows 24:32
If the cell (B15) equals Transition, I want to hide rows 17:24

Below is what I have... but I must be missing something.

----------------
Private Sub Worksheet_Change(ByVal Target As Range)

Application.ScreenUpdating = False
If Range("B15").Value = "" Then
Range(Rows(16), Rows(32)).EntireRow.Hidden = True
ElseIf Range("B15").Value = "Migration" Then
Range(Rows(17), Rows(24)).EntireRow.Hidden = False:
Range(Rows(25), Rows(32)).EntireRow.Hidden = True
ElseIf Range("B15").Value = "Transition" Then
Range(Rows(17), Rows(24)).EntireRow.Hidden = True:
Range(Rows(25), Rows(32)).EntireRow.Hidden = False
End If
Application.ScreenUpdating = True
End Sub
----------------

Any help is appreciated - THANKS!


Hi Shelly

I have tried your code and it works fine here, just notice that the
testvalue is case sensitive.

Btw: I would unhide all rows before i tested which rows to hide and then
juste hide whatever is to be hidden.

Rows("16:32").EntireRow.Hidden = False

Regards,

Per



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 84
Default Hide/Show Rows based on Cell Value with Data Validation

It's working now. The only thing I can think of is that I was trying to do
it while the sheet was in Design Mode. THANKS!!


"Per Jessen" wrote:


"Shelly" skrev i en meddelelse
...
Hello, I've been searching through these forums since last night, but just
can't figure this out. I have a cell with data validation, and 2 values
"Migration" and "Transition".

If the cell (B15) is blank, I want all the rows to be hidden (16:32)
If the cell (B15) equals Migration, I want to hide rows 24:32
If the cell (B15) equals Transition, I want to hide rows 17:24

Below is what I have... but I must be missing something.

----------------
Private Sub Worksheet_Change(ByVal Target As Range)

Application.ScreenUpdating = False
If Range("B15").Value = "" Then
Range(Rows(16), Rows(32)).EntireRow.Hidden = True
ElseIf Range("B15").Value = "Migration" Then
Range(Rows(17), Rows(24)).EntireRow.Hidden = False:
Range(Rows(25), Rows(32)).EntireRow.Hidden = True
ElseIf Range("B15").Value = "Transition" Then
Range(Rows(17), Rows(24)).EntireRow.Hidden = True:
Range(Rows(25), Rows(32)).EntireRow.Hidden = False
End If
Application.ScreenUpdating = True
End Sub
----------------

Any help is appreciated - THANKS!


Hi Shelly

I have tried your code and it works fine here, just notice that the
testvalue is case sensitive.

Btw: I would unhide all rows before i tested which rows to hide and then
juste hide whatever is to be hidden.

Rows("16:32").EntireRow.Hidden = False

Regards,

Per




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hide & Show Rows based on Check Boxes loza Excel Discussion (Misc queries) 1 September 14th 08 01:49 AM
hide / show rows based on two drop down selectiosn Maritza Excel Programming 3 April 1st 07 10:26 AM
Hide/Show a row based on data entry in another row ivory_kitten Excel Programming 7 May 17th 06 12:08 PM
Hide Columns based on a Data Validation List Ricky Pang Excel Programming 4 September 15th 04 02:43 AM
Macro to Hide/Show Columns based on control cell value Steve N Excel Programming 2 May 25th 04 06:51 PM


All times are GMT +1. The time now is 12:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"