-
Solved: Date split
Hey people, Any idea how to do a Date split of a textbox value. i tried this way below but it doesnt seems to display the mm. basically, i have created a 12 sheet(from Jan- Dec) and i want the date from the textbox to split into mm|dd|yyyy. it will first get the mm and it will go into the sheet that the mm falls into. eg, if the mm is 1, den it will go to my Jan sheet. if the mm is 2, then it will go to my Feb sheet.
Dim mySchedule As Variant
mySchedule = txtSchedule.Value
mySchedule = Split("mm|dd|yyyy", "|")
MsgBox (mm)
could anyone please help mi? thanks
-
The Split function returns an array, so:
mySchedule = Split("mm|dd|yyyy", "|")
results in:
mySchedule(0) will be "mm"
mySchedule(1) will be "dd"
mySchedule(2) will be "yyyy"
I think you might want to look at the DatePart function that returns the specified part of a given date[VBA]Const d As Date = "11/08/2006"
Dim strTemp As String
strTemp = "Date: " & d & vbLf & _
"Day: " & DatePart("d", d) & vbLf & _
"Month: " & DatePart("m", d) & vbLf & _
"Year: " & DatePart("yyyy", d)
MsgBox strTemp[/VBA]
K :-)
-
Alternate method
Why not try this instead?
[VBA] If IsDate(txtSchedule.Value) Then
Worksheets(Format$(txtSchedule.Value, "mmm")).Activate
End If[/VBA]
Or if pipe characters are already in your txtSchedule value...
[VBA] If IsDate(Replace(txtSchedule.Value, "|", "/")) Then
Worksheets(Format$(Replace(txtSchedule.Value, "|", "/"), "mmm")).Activate
End If[/VBA]
BFN,
fp.
-
sorry for late reply... thxs ppls=D cheers~
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules