+ Reply to Thread
Results 1 to 12 of 12

Inputting Military time using userform

  1. #1
    Registered User
    Join Date
    09-01-2010
    Location
    California USA
    MS-Off Ver
    Excel 2007
    Posts
    8

    Inputting Military time using userform

    I have a user form that I input data and would like to input military time so I do not need to use the ":" . The data gets added to an excel spreadsheet. I have tried numerous other suggestions and codes that I have found online, but nothing seems to work right. Please help me out, this is really frustrating me.

    - - - - - - - - - - - -- - -- - - -
    Code I am using is here:

    With Me
    c.Value = .TextBox6.Value
    c.**fset(0, 1).Value = .TextBox1.Value
    c.**fset(0, 2).Value = .TextBox3.Value
    c.**fset(0, 3).Value = .TextBox4.Value
    c.**fset(0, 4).Value = CDate(txtshift)
    c.**fset(0, 5).Value = .TextBox2.Value
    c.**fset(0, 6).Value = CDate(txtshift)
    c.**fset(0, 13).Value = .TextBox17.Value
    ClearControls
    End With
    Application.ScreenUpdating = True
    End Sub

    _______________________________
    Private Sub TextBox18_CDate(txtshift)
    TextBox18.Value = Format(.Value, "hh:mm")
    End Sub
    ________________

    Private Sub TextBox19_CDate(txtshift)
    TextBox19.Value = Format(.Value, "hhmm")
    End Sub
    - - - - - - - - - - - - - - - -
    Displays on Excel: (the time section that is not working)
    Qty Start time Breaks Stop time
    400 00:00 30 00:00
    600 00:00 30 00:00
    200 00:00 15 00:00

    Thank you in advance.
    Dave

  2. #2
    Forum Contributor
    Join Date
    04-03-2012
    Location
    Washington State
    MS-Off Ver
    Excel 2013
    Posts
    332

    Re: Inputting Military time using userform

    Are you entering the time manually on the user form? And is that the only reason for wanting military time?

  3. #3
    Registered User
    Join Date
    09-01-2010
    Location
    California USA
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Inputting Military time using userform

    Yes I am entering it manually. And it is the easiest way to enter time since I have many rows ** data that need to be entered each day. When the time is on the excel spreadsheet, I then have another formula on later columns that show the total time elapsed between the start and stop time and figure cost per piece etc.
    Thank you for looking into this.
    Dave

  4. #4
    Forum Contributor
    Join Date
    04-03-2012
    Location
    Washington State
    MS-Off Ver
    Excel 2013
    Posts
    332

    Re: Inputting Military time using userform

    I'm not sure exactly how your data is entered.... but I had a similar need awhile back. I wanted to enter the numbers for hh:mm more quickly. So I am entering 02 minutes & 07 seconds as 0207 and the format changes automatically using this code. Change textbox names to yours. Does this work for you?

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    04-03-2012
    Location
    Washington State
    MS-Off Ver
    Excel 2013
    Posts
    332

    Re: Inputting Military time using userform

    I forgot to mention... two minutes and seven seconds is entered like this 207

  6. #6
    Registered User
    Join Date
    09-01-2010
    Location
    California USA
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Inputting Military time using userform

    Well, I am not that sophisticated at VBA, I tried your code, but its not working. I do not know how to get this to be the code for the input cell that I am trying to enter the time.

  7. #7
    Forum Contributor
    Join Date
    04-03-2012
    Location
    Washington State
    MS-Off Ver
    Excel 2013
    Posts
    332

    Re: Inputting Military time using userform

    On your userform, you would place this code in example: TextBox1_AfterUpdate()

    Then this time will submit to your worksheet like you are doing now. If you can, post a copy ** your workbook (take out any personal info).

  8. #8
    Registered User
    Join Date
    09-01-2010
    Location
    California USA
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Inputting Military time using userform

    I am trying to enter the time ** the day, say 6:30 am = 0630 and end time ** 3:30pm = 1530. And I want this to display as the military time on the excel spreadsheet. Then I can hopefully use another excel formula to display 9.0 hours or 540 minutes.

  9. #9
    Registered User
    Join Date
    09-01-2010
    Location
    California USA
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Inputting Military time using userform

    Quote Originally Posted by Nu2Java View Post
    On your userform, you would place this code in example: TextBox1_AfterUpdate()

    Then this time will submit to your worksheet like you are doing now. If you can, post a copy ** your workbook (take out any personal info).
    Do you mean replace everywhere it says txtTProcTime with TextBox18 ?

  10. #10
    Forum Contributor
    Join Date
    04-03-2012
    Location
    Washington State
    MS-Off Ver
    Excel 2013
    Posts
    332

    Re: Inputting Military time using userform

    Yes. Replace those with your textboxes. You can also use it as military time, it will just show the colons on the sheet but will be automated.

  11. #11
    Registered User
    Join Date
    09-01-2010
    Location
    California USA
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Inputting Military time using userform

    Nu2Java, Thank you so much. It works great. I had to also change the command portion of the code back to just sending the value of TextBox18 and everything fell into place. I really appreciate the very clear and concise help.

    Dave

  12. #12
    Forum Contributor
    Join Date
    04-03-2012
    Location
    Washington State
    MS-Off Ver
    Excel 2013
    Posts
    332

    Re: Inputting Military time using userform

    No problem, glad I could help you out.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Userform Label Caption - How To Set It To Display Military Time?
    By ScotyB in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-15-2013, 06:27 PM
  2. Simple way to convert military time to standard where military has no colon
    By salvator in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-03-2011, 10:27 AM
  3. Inputting pictures into UserForm
    By DCHill in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-11-2009, 05:58 AM
  4. Format a Userform textbox to Military time
    By Christy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-24-2005, 06:05 PM
  5. [SOLVED] Entering military time into a userform
    By WillRn in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-14-2005, 12:06 PM

Tags for this Thread

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