Timer mm:ss in textbox VBA

MmonkeyDX

New Member
Joined
Feb 18, 2021
Messages
2
Office Version
  1. 2019
Platform
  1. Windows
Hi all,
I have a problem with textboxes in userform.
Basically i just want to display one cell with a timer inside through one textbox in my userform.

In C2 i have a timer and the cell format is "mm:ss", so the textbox2 should display that cell in that format but it seems so complicate.
If the "ControlSource" of textbox2 is C2, then the value is something like this: "6,94444444444444E-05".
So i've used the code below but the timer goes mad and goes directly to 12:00:00 in the c2 cell and 0,5 in the textbox
VBA Code:
Private Sub TextBox2_Change()
    TextBox2 = Format(TextBox2, "mm:ss")
End Sub

With this code there are no problems and the time is shown in hh:mm:ss but i need mm:ss
Code:
Private Sub TextBox2_Change()
    TextBox2 = Format(TextBox2, "hh:mm:ss")
End Sub

So i've changed it to
Code:
Private Sub TextBox2_Change()

TextBox2 = Right(Format(TextBox2, "hh:mm:ss"), 5)

End Sub

In this way the hours are hidden but the timer is freezed to 00:00 and i don't know why

Any solution for this problem? I can't belive there isn't an easy way to display in a textbox the content of a cell with timer inside.
Thank you so much for help
 

Some videos you may like

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).

diddi

Well-known Member
Joined
May 20, 2004
Messages
3,264
Office Version
  1. 2010
Platform
  1. Windows
can you run the timer on the userform. the removes the linking problem you are having
 

MmonkeyDX

New Member
Joined
Feb 18, 2021
Messages
2
Office Version
  1. 2019
Platform
  1. Windows
Of course this is an option, but i think that the textbox format problem's still remain :/
 

diddi

Well-known Member
Joined
May 20, 2004
Messages
3,264
Office Version
  1. 2010
Platform
  1. Windows
thats is the point. unlink the textbox from the worksheet. run the timer on the userform and update the cell periodically. i assume the userform is the front window, so if the sheet is not updated every second it wont matter anyway.
 

Watch MrExcel Video

Forum statistics

Threads
1,127,100
Messages
5,622,717
Members
415,922
Latest member
gemmatay88

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
Top