Multiple row/cell realtime count

akaseto

New Member
Joined
Oct 10, 2021
Messages
18
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hello,
i have a mini bike rent and im trying to make a time tracking for my clients spent time
this is my code
VBA Code:
Sub trycouunt()
Dim starts As Single
Dim cntup As Date
Dim cntdwn As Date
Set ws = ActiveSheet
Dim j As Long
Clock = Now + TimeValue("00:00:01")
starts = Timer
For i = 2 To 6
cntup = CellS(i, 1).Value 'this is part i cant understand why my code didnt work
cntdwn = CellS(i, 2).Value 'this is part i cant understand why my code didnt work
If CellS(i, 1).Value > 0 Then
    CellS(i, 1).Value = cntup - (Timer - starts - 86400 * (starts > Timer)) / 86400
    CellS(i, 2).Value = cntdwn + (Timer - starts - 86400 * (starts > Timer)) / 86400
End If
Next i

Application.OnTime Clock, "trycount"
End Sub

1697863141639.png


if only 1 cell its work with this code :
VBA Code:
Sub RunMe()

Dim starts As Single
Dim CellS As Range
Dim Cellt As Range
Dim CountUPS As Date
Dim CountUp As Date

'Timer is the number of seconds since midnight.
'Store timer at this point in a variable
starts = Timer

'Store A1 in a variable to make it easier to refer
'to it later. Also, if the cell changes, you only
'have to change it in one place
Set CellS = Sheet1.Range("A1")
CountUPS = Sheet1.Range("A1").Value

Set Cellt = Sheet1.Range("B1")
CountUp = Sheet1.Range("B1")

'b_pause = True
Do While CellS.Value > 0

    CellS.Value = CountUPS - (Timer - starts - 86400 * (starts > Timer)) / 86400
    Cellt.Value = CountUp + (Timer - starts - 86400 * (starts > Timer)) / 86400
    DoEvents
Loop

End Sub
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
This is a good starting point for the above problem. Hope it helps:
link
thanks for the reply, i apreciate it so much
when i left userform or stop count, its not a realtime clock monitoring, only when the code is running
and i figured out to do that by adding some helper value

1697865140978.png
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,959
Members
449,096
Latest member
Anshu121

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top