Consulting

Results 1 to 4 of 4

Thread: Solved: Date split

  1. #1

    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

  2. #2
    VBAX Master Killian's Avatar
    Joined
    Nov 2004
    Location
    London
    Posts
    1,132
    Location
    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 :-)

  3. #3
    VBAX Regular fanpages's Avatar
    Joined
    Jun 2004
    Location
    United Kingdom
    Posts
    7
    Location

    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.

  4. #4
    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
  •