Hi,
How to make the Time will be showing continuously updating while other subroutine is running?
I have problem the Time is stop while the subroutine is executing.
Thank you in advance for your helps.
File as reff.
Iqballhud
Hi,
How to make the Time will be showing continuously updating while other subroutine is running?
I have problem the Time is stop while the subroutine is executing.
Thank you in advance for your helps.
File as reff.
Iqballhud
This seems to work well enough:
A video of it working https://1drv.ms/v/s!AkG6_LvJpkR7j61W...S5umQ?e=sgnZsy![]()
Dim showTime As Boolean ' whether or not the timeloop should run Private Sub btnCopyCells_Click() ' copy some cell data - like normal Dim rowIndex As Long For rowIndex = 7 To 16 Sheet1.Cells(rowIndex, 5).Value = Sheet1.Cells(rowIndex, 3).Value DoEvents ' include this in your other subroutine to allow the clock to run Next rowIndex End Sub Private Sub btnStart_Click() ' begin displaying the current time until the button ' is clicked again to stop the time Dim s As Single Dim theTime As Double Dim displayTime As Variant If btnStart.Caption = "Start Clock" Then ' switch the caption on the button so it can be used to stop the time btnStart.Caption = "Stop Clock" showTime = True DoEvents ' this comment instructs VBA to allow Excel to refresh the display Else ' stop the clock and switch back to a start button btnStart.Caption = "Start Clock" showTime = False DoEvents End If ' show the current time, using the timer() Do Until Not showTime s = Timer() theTime = s / (86400) displayTime = Format(theTime, "hh:mm:ss") Sheet1.Cells(1, 1).Value = displayTime DoEvents Loop End Sub
Hi @iqballud. You only had to add one line in the InitialRunPL1 procedure. I think you'll find your mistake.It was my pleasure to help you. Good luck.![]()
Sub InitialRunPL1() Dim A As Integer A = 88 Application.StatusBar = True Const valIncrement As Double = 0.1 Const indexCalc As Single = 0 Dim intMax As Integer Dim intIndex As Integer Dim intCalc As Double intMax = 50 For intIndex = 1 To intMax DoEvents intCalc = intCalc + valIncrement UserForm1.Label1 = Time UserForm1.Label2 = Round(intCalc, 1) UserForm1.Label2 = Format(intCalc, "0.000") Sleep A Next Application.StatusBar = False End Sub
NOTE: As the original poster/owner, only you can mark your thread as SOLVED (Thread Tools above Post #1).
You can say "Thanks" in your thread to everyone who offered to help you.
You can also reward them by clicking * "Add Reputation" under their username on the left.
With Regards, MikeVol.
Hi,
Thank you so much for "jdelano" & "MikeVol".
To MikeVol, yes you are right, i didn't added the time on the DoEvents procedure. It's working fine now.
To jdelano, another way to do coding. I wish I will use this code for another projects.
Again thank you so much Guys.
Cheers, Iqballhud
You're welcome, I'm glad you got your code working.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks