#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 221
Default Case Select

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.




  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
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.






  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 221
Default Case Select

Thank you Bob

Appreciate the assistance

Regards
Mark.


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 221
Default Case Select

Bob

Just a couple of follow up questions if I may.

1. the date format in your response, is it

(yyyy,mm,dd) or (yyyy,dd,mm)

2. with the 'Do Something

What would be the best way to set the focus of then Target.Value Cell +1
Cell to the right.

By that I mean, if the the target cell a1, then I need "response" in b1.

Regards
Mark.


  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 221
Default Case Select

Bob

Sorry to be a pest.

Seems I can't use this code.

Keep getting Compile Error: Ambiguous Name Detected (Worksheet_Change)

I'm fairly certain it has to do with the DateTime picker:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("G5:G2004")) Is Nothing Then
If DTPicker1.Visible Then DTPicker1.Visible = False
End If
End Sub

Any thoughts.
Mark.




  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,420
Default Case Select

That means that you already have a Worksheet_Change event procedure, so you
need to amalgamate them.

--
__________________________________
HTH

Bob

"NoodNutt" wrote in message
...
Bob

Sorry to be a pest.

Seems I can't use this code.

Keep getting Compile Error: Ambiguous Name Detected (Worksheet_Change)

I'm fairly certain it has to do with the DateTime picker:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("G5:G2004")) Is Nothing Then
If DTPicker1.Visible Then DTPicker1.Visible = False
End If
End Sub

Any thoughts.
Mark.



  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 221
Default Case Select

Thx again Bob.

Just a couple of follow up questions if I may.

1. the date format in your response, is it

(yyyy,mm,dd) or (yyyy,dd,mm)

2. with the 'Do Something

What would be the best way to move the focus from the Target.Value Cell, to
the Cell at the immediate right.

By that I mean, if the Target. Value Cell = G5, then I need the response in
H5 to = "SEP".

Regards
Mark.


  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 221
Default Case Select

Bob

After mucking around for a while I managed to work it through and got the
result I was looking for.

Once again thx heaps for your assistance & patience.

Regards
Mark.


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
Case without Select Case error problem Ayo Excel Discussion (Misc queries) 2 May 16th 08 03:48 PM
Minimum value after select case Gimp Excel Worksheet Functions 3 January 9th 07 02:58 PM
Select Case Jeff Excel Discussion (Misc queries) 1 February 27th 06 02:56 PM
VBA select case question Jeff Excel Discussion (Misc queries) 2 January 27th 06 03:03 AM
Need help on Select Case Susan Hayes Excel Worksheet Functions 1 November 3rd 04 10:25 PM


All times are GMT +1. The time now is 02:49 AM.

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

About Us

"It's about Microsoft Excel"