Hello, I'm new to this forum and have searched it over and over to try and find a solution to this. I've come close to getting the right code (I think..) but my lack of knowledge about VBA is leading to a simple mistake in my code I'm guessing..
I'm trying to have rows disappear on one worksheet based on a drop-down menu on another worksheet that has 12 months to select from. I will be replicating this code for multiple other worksheets that will act in a similar way.
Here's the code I've come up with;
As you can see, I'm trying to get the rows to hide based on the value in C4. However, the only month that seems to be working is December (or whatever month is listed last). What am I missing to fix this?
I'm using Office 2007 on a laptop loaded with Windows XP SP3.
Thoughts?
I'm trying to have rows disappear on one worksheet based on a drop-down menu on another worksheet that has 12 months to select from. I will be replicating this code for multiple other worksheets that will act in a similar way.
Here's the code I've come up with;
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
With Sheets("PI")
Select Case Target.Address(False, False)
Case "C4"
.Rows("69:900").Rows.Hidden = Target.Value = "January"
.Rows("5:68").Rows.Hidden = Target.Value = "February"
.Rows("133:900").Rows.Hidden = Target.Value = "February"
.Rows("5:132").Rows.Hidden = Target.Value = "March"
.Rows("197:900").Rows.Hidden = Target.Value = "March"
.Rows("5:196").Rows.Hidden = Target.Value = "April"
.Rows("261:900").Rows.Hidden = Target.Value = "April"
.Rows("5:260").Rows.Hidden = Target.Value = "May"
.Rows("325:900").Rows.Hidden = Target.Value = "May"
.Rows("5:324").Rows.Hidden = Target.Value = "June"
.Rows("389:900").Rows.Hidden = Target.Value = "June"
.Rows("5:388").Rows.Hidden = Target.Value = "July"
.Rows("453:900").Rows.Hidden = Target.Value = "July"
.Rows("5:452").Rows.Hidden = Target.Value = "August"
.Rows("517:900").Rows.Hidden = Target.Value = "August"
.Rows("5:516").Rows.Hidden = Target.Value = "September"
.Rows("581:900").Rows.Hidden = Target.Value = "September"
.Rows("5:580").Rows.Hidden = Target.Value = "October"
.Rows("645:900").Rows.Hidden = Target.Value = "October"
.Rows("5:644").Rows.Hidden = Target.Value = "November"
.Rows("709:900").Rows.Hidden = Target.Value = "November"
.Rows("5:708").Rows.Hidden = Target.Value = "December"
.Rows("773:900").Rows.Hidden = Target.Value = "December"
End Select
End With
End Sub
As you can see, I'm trying to get the rows to hide based on the value in C4. However, the only month that seems to be working is December (or whatever month is listed last). What am I missing to fix this?
I'm using Office 2007 on a laptop loaded with Windows XP SP3.
Thoughts?