Timestamping

raven1124

New Member
Joined
Jun 13, 2017
Messages
29
Hello Everyone,

Seeking for your assistance to fix how timestamping should work

I tried different ways of using Now() to store the time but when I try to it sometimes, it doesn't provide my ideal difference in (hh:mm:ss)

Or sometimes it gives me the actual time. please help

Code:
Sub timeinout()


Time1 As Date
Time2 As Date
TimeDifference As Date




If Sheet1.Shapes(Application.Caller).TextFrame.Characters.Text = "IN" Then
    Sheet1.Shapes(Application.Caller).TextFrame.Characters.Text = "OUT"
    Time1 = Format(DateTime.Now, "hh:mm:ss")


ElseIf Sheet1.Shapes(Application.Caller).TextFrame.Characters.Text = "OUT" Then
    Sheet1.Shapes(Application.Caller).TextFrame.Characters.Text = "IN"
    Time2 = Format(DateTime.Now, "hh:mm:ss")
    TimeDifference = Time1 - Time2
    
    MsgBox (TimeDifference)
    
Else
    'DO nothing
End If


End Sub
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Just use NOW() ,no format. You want the entire Date-time in case the clock goes past midnight.

Time1=now()
msgbox(DateDiff("m",time1,time2)

this gives the elapsed time in minutes. You can do hours (or whatever),by changing the 1st param.
 
Upvote 0
Hello Ranman,

I tried to check your recommendation and it worked!

My only question here is how can I convert the result into readable minutes or seconds?
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,185
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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