I want to create 1 button with two function for my timer it should be like Start and Pause I' using userform.
Please Login or Register to view this content.
Please Login or Register to view this content.
I want to create 1 button with two function for my timer it should be like Start and Pause I' using userform.
Please Login or Register to view this content.
Please Login or Register to view this content.
Last edited by N323100; 07-19-2017 at 07:48 AM.
Hi,
The following code will pause timing. When PauseOrRestartTimer() is called a second time, the count will resume from the pause time. Slightly different logic is required to keep the timer running while the display is paused.
NOTE: For resolution to one hundredth of a second see Timer. http://www.excelfunctions.net/vba-timer-function.htmlPlease Login or Register to view this content.
Lewis
Thanks for the inputs.
I attached the file and put the following codes accordingly, but its not working properly I'm not sure if I did it right?
Thank you
One small error.
In the UserForm code module, you used 'StartTimer()', when 'StartStopWatch()' should have been used.
Please Login or Register to view this content.
Thank you this is a great help!
Last edited by N323100; 07-20-2017 at 07:04 AM.
I have a follow up question. I want to trigger the StartStopWatch but completing to fillin' up the ComboBox6 but the only problem if the time that the user change the information in ComBobox6 the StartStopWatch will return to 00:00:01
here are the details of my ComboBox
and also I have this code in submit buttonPlease Login or Register to view this content.
but the textbox or time still running it doesn't remove in textbox. I tried to pause the time and click the submit button and the time in textbox was removed. maybe it should be stop the time first before it was cleared or removed in textbox?Please Login or Register to view this content.
I would appreciate if there is a easy way to my dilemma.
Thank you
Last edited by N323100; 07-20-2017 at 10:02 AM.
The following may help you. If not I will come up with a working example for you:
a. StartStopWatch() should only be called when you want to start from 0:00.
b. PauseOrRestartTimer() will 'pause' the 'stopwatch' if it is running. PauseOrRestartTimer() will make the 'stopwatch' continue from the value that is currently in the display, if it was 'paused'.
Yeah I'm using that code and it works perfectly. The only problem is I have a submit button that will transfer the data including the time into another sheet, once the submit button was click by the user all of the information in userform will be empty or delete to enter a new information again. but the time still shows up in textbox3 even I already put a code the delete or empty the textbox. Thank you for helping me with this project.
I need to see a sample file that demonstrates the problem. The symptoms suggest that data must be stored somewhere at the beginning of the 'Submit' routine, and then the data must be restored later.The only problem is I have a submit button that will transfer the data including the time into another sheet, once the submit button was click by the user all of the information in userform will be empty or delete to enter a new information again. but the time still shows up in textbox3 even I already put a code the delete or empty the textbox.
I will upload the file....thanks
Please see attached file.. Please refer to Activity Tracker Userform. Thanks for patiently helping
Last edited by N323100; 07-21-2017 at 08:59 AM.
If I understand your question correctly, after you select 'Submit', you want TextBox3 to be blank.
You cleared the contents of the TextBox, but you did not stop the timer first, so the timer continued to run, and kept updating the value in TextBox3. If you add the item in red below to the UserForm code, you will probably fix your problem:
LewisPlease Login or Register to view this content.
Hi Thanks you, I tried the above code but still the timer shows after the submit button.
Sorry for the problem. When CommandButton4 (i.e. Submit) called MsgBox it Timer requests queued up, and caused StopTimer() to not work properly. StopTimer() must be the first command in UserForm code for CommandButton4_Click() (Submit) and also in CommandButton3_Click() (Reset/Close).
The attached file implements those changes and hopefully will work the way you want.
In the ActivityTracker UserForm code module:
Please Login or Register to view this content.
Last edited by LJMetzger; 07-23-2017 at 04:39 PM.
This is perfect! Thank you for your BIG Help with this project.
Now you see the userform for activity tracker I'm planning to remove the Start Time button and leave the Pause/Resume button, I want to start the time if the TextBox and ComboBox has a information on it, before a I tried to create that conditional but if there is a chance the a user change something on any of the textbox or combobox the Timer Restart to 0. Sorry if I make everything complicated
Last edited by N323100; 07-24-2017 at 04:54 AM.
It was my pleasure to help. When I have a lot of options like you have on the UserForm, I find the logic to be easier to control if I:
a. Create separate CommandButtons for each task, instead of sharing.
b. Create a separate Sub to Display or Hide CommandButtons as required.
For example: When the UserForm is opened, the 'Start' CommandButton is visible and the 'Pause' CommandButton is not visible.
When the timer starts, then the 'Start' CommandButton is not visible, and the 'Pause' CommandButton is visible.
Actually my plan is to removed the Start Button and put a conditional statement if all the corresponding textbox and combox is not empty the start will start thank you for all the help
Hi I got an issue again in emptying the Timer
Reset Button under different UserForm.
Thank you,Please Login or Register to view this content.
Last edited by N323100; 07-26-2017 at 09:24 AM.
Hi,
I can't see anything wrong with the code. My speculation is that there is something somewhere that says 'timer' instead of 'timer1'.
Instead of creating multiple timers see the attached file which contains the following code changes in red, that should allow you to use the same timer code for all your UserForms.
In the ThisWorkbook code module (to make sure the timer terminates properly):
In the ActivityTracker UserForm code module (to make sure the timer terminates properly):Please Login or Register to view this content.
In ordinary code module module2 (timer code):Please Login or Register to view this content.
In the Task Sheet (Sheet2) code module:Please Login or Register to view this content.
If this does not solve your problem, please upload a sample file that does not work properly.Please Login or Register to view this content.
Lewis
Wow this is perfect!! Thank you once again!!
Hi I have a different question but now once is replying, can you help me with that?
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks