VBA Code for TextBox & SpinButton To set Time Format
Results 1 to 4 of 4

Thread: VBA Code for TextBox & SpinButton To set Time Format
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    Apr 2013
    Location
    UK
    Posts
    219
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default VBA Code for TextBox & SpinButton To set Time Format

    Hi can anyone tell me if itís possible to have a two TextBox 1&2 with two SpinButton 1&2 that sits in a userform so when the user presses the SpinButton 1 it drops a time format into say cell A1which would be known as leave and by pressing SpinButton 2 it drops a time format into say cell A2 which would be known as return . Also can the leave TextBox 1 , when the user form is open, be set at the know time.
    Thank you

  2. #2
    Board Regular My Aswer Is This's Avatar
    Join Date
    Jul 2014
    Posts
    15,737
    Post Thanks / Like
    Mentioned
    28 Post(s)
    Tagged
    13 Thread(s)

    Default Re: VBA Code for TextBox & SpinButton To set Time Format

    Put these three scripts in your UserForm:
    Code:
    Private Sub SpinButton1_Change()
    'Modified  8/7/2019  2:57:00 PM  EDT
    Cells(1, 1).Value = Format(Time, "HH:MM:SS")
    End Sub
    Private Sub SpinButton2_Change()
    'Modified  8/7/2019  2:57:00 PM  EDT
    Cells(2, 1).Value = Format(Time, "HH:MM:SS")
    End Sub
    Private Sub UserForm_Initialize()
    'Modified  8/7/2019  2:57:00 PM  EDT
    TextBox1.Value = Format(Time, "HH:MM:SS")
    End Sub
    Be sure and always test this script on sample data the first time you use this as to avoid any problems with your data. Always trying to learn more and help others where I can. I'm using Excel 2013.
    Patience please Iím not perfect yet. "Memories are forever"

  3. #3
    Board Regular
    Join Date
    Apr 2013
    Location
    UK
    Posts
    219
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA Code for TextBox & SpinButton To set Time Format

    Thank you that helps me so much

  4. #4
    Board Regular My Aswer Is This's Avatar
    Join Date
    Jul 2014
    Posts
    15,737
    Post Thanks / Like
    Mentioned
    28 Post(s)
    Tagged
    13 Thread(s)

    Default Re: VBA Code for TextBox & SpinButton To set Time Format

    Glad I was able to help you.
    Come back here to Mr. Excel next time you need additional assistance.
    Quote Originally Posted by Malcolm torishi View Post
    Thank you that helps me so much
    Be sure and always test this script on sample data the first time you use this as to avoid any problems with your data. Always trying to learn more and help others where I can. I'm using Excel 2013.
    Patience please Iím not perfect yet. "Memories are forever"

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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