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

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
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,214,945
Messages
6,122,395
Members
449,081
Latest member
JAMES KECULAH

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