PDA

View Full Version : find substring and display message box



Malek
11-05-2007, 09:28 AM
I have a set of dates in excel that I need to be able to loop through however the starting dates are not always on the first and so I need to be able to determine the day but not the year or month. What I have is not working


checkDates (ActiveCell.Value)

Please note that there is a difference in the case statements simply because I am trying to get the first one to work and then I will modify the rest based off of that one.


Sub checkDates(day As String)

Dim mth As String
Dim dy As String
Dim yr As String

'MsgBox day

Select Case day
Case1 "/1/" Like "*" & day & "*":
MsgBox "day one"
Case day Like "*/2/*"
Case day Like "*/3/*":
Case day Like "*/4/*":
Case day Like "*/5/*":
Case day Like "*/6/*":
Case day Like "*/7/*":

Case Else
MsgBox "test"
End Select

Thank you

Norie
11-05-2007, 09:36 AM
Why not just extract the day using the Day function?

Malek
11-05-2007, 09:40 AM
Why not just extract the day using the Day function?

Probably because I am not aware of that one or how it works...do mind helping me with some examples.

Malek
11-05-2007, 11:22 AM
*bump

Norie
11-05-2007, 12:52 PM
Well if you have a date you can easily extract the day.

For example:

Msgbox Day(Date)

Malek
11-05-2007, 12:54 PM
well that won't compile in my version of Office(2003)

and there is nothing in the help file about it.

Norie
11-05-2007, 01:00 PM
Well the reason it won't compile could be because you've declared a variable called day.

And since Day is a VBA function that's not a good idea.:)

Malek
11-05-2007, 01:19 PM
:banghead: and I knew that too..thanx.

I ended up just using DatePart instead.