Minus Time from Time VBA

Qmustard

New Member
Joined
Sep 27, 2016
Messages
37
Hi all,

Hoping this is an easy problem to fix!

I have the following in my <acronym title="visual basic for applications">VBA on the two seperate Userforms</acronym>:


Code:
Userform1.Time.Caption = Format(Now, "hh:mm:ss AMPM")

Userform2.Endtime.Caption = Format(Now, "hh:mm:ss AMPM")

Is it at all possible to subtract one from the other in <acronym title="visual basic for applications">VBA</acronym> to get the difference?

I've tried:


Code:
difference.caption = endtime.caption - time.caption

But it just errors on me, telling me its TYPE MISMATCH.

I'm basically looking for a quick way to see what time is on the first userform the user uses and then the time on the last form they use, to work out exactly how long it has taken them to get from one to the other.
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Hi, you could try something like this:

Code:
difference.Caption = Format(TimeValue(EndTime.Caption) - TimeValue(Time.Caption), "hh:mm:ss")
 
Upvote 0

Forum statistics

Threads
1,215,734
Messages
6,126,543
Members
449,316
Latest member
sravya

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