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 calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
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,216,079
Messages
6,128,687
Members
449,464
Latest member
againofsoul

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