Results 1 to 4 of 4

Changing date format

Threaded View

  1. #1
    Registered User
    Join Date
    09-21-2011
    Location
    INDIA
    MS-Off Ver
    Excel 2007
    Posts
    17

    Changing date format

    I have prepared a small vba user form for entering the leave details. While entering the date in "From" and "To" fields (text boxes)in teh format dd/mm/yyyy, the data is written in the excel sheet as mm/dd/yyyy. Please help to rectify the error.
    I am appending the script...


    Private Sub cmdClose1_Click()
        Unload Me
    End Sub
    Private Sub cmdOK1_Click()
        Dim RowCount As Long
        Dim ctl As Control
        If Not IsNumeric(Me.txtEmp.Value) Then
            MsgBox "The Employee Number is Wrong.", vbExclamation, "Error"
            Me.txtEmp.SetFocus
            Exit Sub
        End If
    
        If Not IsDate(Me.txtFrom.Value) Then
            MsgBox "Please Enter the From Date Correctly.", vbExclamation, "Error"
            Me.txtFrom.SetFocus
            Exit Sub
        End If
    
        If Not IsDate(Me.txtTo.Value) Then
            MsgBox "Please Enter the To Date Correctly.", vbExclamation, "Error"
            Me.txtTo.SetFocus
            Exit Sub
        End If
    
    
        If Me.txtDays.Value = "" Then
            MsgBox "Please Enter No of Days.", vbExclamation, "Error"
            Me.txtDays.SetFocus
            Exit Sub
        End If
    
        RowCount = Worksheets("Data").Range("A1").CurrentRegion.Rows.Count
        
        With Worksheets("Data").Range("A1")
            .Offset(RowCount, 0).Value = Me.txtEmp.Value
            .Offset(RowCount, 1).Value = Me.txtFrom.Value
            .Offset(RowCount, 2).Value = Me.txtTo.Value
            .Offset(RowCount, 3).Value = Me.txtDays.Value
            .Offset(RowCount, 4).Value = Me.cboType.Value
        End With
    
        For Each ctl In Me.Controls
            txtEmp.Text = ""
            txtFrom.Text = ""
            txtTo.Text = ""
            txtDays.Text = ""
        Next ctl
    End Sub
    Last edited by arlu1201; 11-04-2012 at 09:33 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1