Thread: Case Select
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bob Phillips[_3_] Bob Phillips[_3_] is offline
external usenet poster
 
Posts: 2,420
Default Case Select

Private Sub Worksheet_Change(ByVal Target As Range)

If Not Intersect(Target, Me.Range("G5:G2004")) Is Nothing Then

' I have used the [Between] & [And], and the # around the dates _
as I use this in Access and thought it easier to express what _
I am attempting to achieve.

Select Case True

Case Target.Value = DateSerial(2008, 1, 1) And Target.Value <
DateSerial(2008, 2, 1)

'do something

Case Target.Value = DateSerial(2008, 1, 2) And Target.Value <
DateSerial(2008, 3, 1)

'do something

Case Target.Value = DateSerial(2008, 1, 3) And Target.Value <
DateSerial(2008, 4, 1)

'do something

'etc.
End Select
End If

End Sub




--
__________________________________
HTH

Bob

"NoodNutt" wrote in message
...
G'day Everyone

Using Excel 2K - 2K3 compatible format
Range("G5:G2004") is setup with DateTime Picker.

Was hoping to setup a Case Select Statement

Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("'2008'!G5:G2004")) Is Nothing Then

' I have used the [Between] & [And], and the # around the dates as I use
this in Access and thought it easier to express what I am attempting to
achieve.

Case Select
IF("'2008'!G5:G2004"=[Between] #01-Jan-08# [And] #31-Jan-08#,
"'2008'!F5:F2004"="JAN")

ElseIF ("'2008'!G5:G2004"=[Between] #01-Feb-08# [And] *#28-Feb-08#,
"'2008'!F5:F2004"="FEB")
ElseIF ("'208'!G5:G2004"=[Between] #01-Mar-08# [And] #31-Mar-08#,
"'2008'!F5:F2004"="MAR")

And so on upto "DEC"

the bracketed [] comments are for explaination clarity only, they are not
NameRanges
*no automation is required for leap year as code will be updated annually
when new sheet is created.

I look for to any suggestions
TIA
Mark.