+ Reply to Thread
Results 1 to 8 of 8

ComboBox Time Value/Command button click update

  1. #1
    Registered User
    Join Date
    06-09-2011
    Location
    Denver
    MS-Off Ver
    Excel 2007
    Posts
    25

    ComboBox Time Value/Command button click update

    Attach workbook has a user form.

    I have it close to functioning the way I need it to.

    What I can't figure out is how to format the ComboBox to display the selected time (in minutes) and not a decimal value - if I select 00:01:00 it should stay 00:01:00.

    Second, I need the times (labels where time calculation is displayed) to update every time the command button is clicked from the values in the ComboBoxs.

    Also, it enters debug if the ComboBox times are selected first before clicking the command button, how can I get around this?

    Any help is appreciated!

    Thank you.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: ComboBox Time Value/Command button click update

    try this version
    Attached Files Attached Files
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: ComboBox Time Value/Command button click update

    Hi hwtcrl,

    Welcome to the joys of Excel time formatting. See the attached updated workbook. I changed the following:
    a. I changed your cells in Column 'A' to text format by putting an apostrophe in front of each value. Although Excel displays the values as text, it really stores the values as a real number 0 <= x < = 1 as a fraction of a day. e.g. 0.25 is 6AM.

    b. I changed the UserForm code to add the times and then convert them to display in PrettyPrint format:
    Please Login or Register  to view this content.
    Complete UserForm code follows:
    Please Login or Register  to view this content.
    Lewis
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    06-09-2011
    Location
    Denver
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: ComboBox Time Value/Command button click update

    Quote Originally Posted by LJMetzger View Post
    Hi hwtcrl,

    Welcome to the joys of Excel time formatting. See the attached updated workbook. I changed the following:
    a. I changed your cells in Column 'A' to text format by putting an apostrophe in front of each value. Although Excel displays the values as text, it really stores the values as a real number 0 <= x < = 1 as a fraction of a day. e.g. 0.25 is 6AM.

    b. I changed the UserForm code to add the times and then convert them to display in PrettyPrint format:

    Lewis
    Quote Originally Posted by mehmetcik View Post
    try this version
    Lewis/mehmetcik

    Thank you for the corrections, however I would like to be able to click the command button multiple times and each time update, not just current time, no matter when the user clicks the button the times they have selected in the combobox will update

  5. #5
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: ComboBox Time Value/Command button click update

    Ok try this:

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by mehmetcik; 04-30-2015 at 01:09 PM.

  6. #6
    Registered User
    Join Date
    06-09-2011
    Location
    Denver
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: ComboBox Time Value/Command button click update

    Quote Originally Posted by mehmetcik View Post
    Ok try this:
    Let me restate the purpose of each entity.

    The command button should display time now() next to it (where it says <--Time Now) whenever the user clicks the button.

    Each combobox should display the user selected time in minutes, if they choose 5 in the first, 7 in the second, 10 in the third it should stay 5,7,10 and not change.

    The Time1-3 to the right of each combobox should display the computed time (time now value + combobox minute selection value) based upon the user combobox selections.

    No matter when the user clicks the command button the time now updates, as well as the computed times to the right of each combobox.

    The combobox values should never change unless the user changes them.

  7. #7
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: ComboBox Time Value/Command button click update

    Hi hwtcrl,

    Try the following code which is included in the updated attached file. Please note that the 'TimeNow' value only changes when 'CommandButton1' is Activated.

    UserForm1 Code Module:
    Please Login or Register  to view this content.
    Lewis
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    06-09-2011
    Location
    Denver
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: ComboBox Time Value/Command button click update

    Quote Originally Posted by LJMetzger View Post
    Hi hwtcrl,

    Try the following code which is included in the updated attached file. Please note that the 'TimeNow' value only changes when 'CommandButton1' is Activated.

    UserForm1 Code Module:


    Lewis



    And Lewis does it! Thank you so much for the help everything works like a charm!

+ 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. use a command button to click other command buttons
    By fcharl9 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-20-2013, 08:48 PM
  2. Automatically update existing data using a Update command button
    By 9999335 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-23-2012, 09:46 PM
  3. UserForm, update after command button click
    By ker9 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-01-2010, 01:05 PM
  4. VBA Click Command Button
    By Benz in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-04-2006, 04:30 PM

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