+ Reply to Thread
Results 1 to 2 of 2

Add time in a form with desired format

Hybrid View

  1. #1
    Registered User
    Join Date
    10-10-2008
    Location
    Illinois
    MS-Off Ver
    Microsoft Office Excel 2003
    Posts
    85

    Add time in a form with desired format

    I have a form with an In and Out Time. I want the user to input the time with no colon and no AM or PM. Then a Calculate button will give the total hours. Is this possible and the am pm is not necessary but would be helpful. Attached is a sample form that does work when the time is entered in as 12:00:00 AM format. Thank you for any help.
    Attached Files Attached Files

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,486
    Maybe try this
    Private Sub CommandButton1_Click()
        If TimeOut - TimeIn < 1000 Then
            TotalHours = (Left((TimeOut - TimeIn), 1) & ":" & Right((TimeOut - TimeIn), 2))
        Else
            TotalHours = (Left((TimeOut - TimeIn), 2) & ":" & Right((TimeOut - TimeIn), 2))
        End If
        Range("A1") = TotalHours
    
    End Sub

+ Reply to Thread

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