Need timer to be displayed on two different screens

Pookiemeister

Well-known Member
Joined
Jan 6, 2012
Messages
626
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
I found this code online. It is a stopwatch timer. This file is stored in MS Teams/Sharepoint on a server. There are two rooms that is separated by a wall. Each room's computer has access to this file. So what I am wanting to do is if one rooms opens this file and starts the timer and the other room opens the file, both rooms need to see the exact numbers on the timer. I hope my explanation makes sense. Is this even possible? From what I have read, it is not possible to run Macros inside these apps. Is there any other way to achieve this? Thank you.

VBA Code:
Private Sub Workbook_Open()
    UserForm1.Show
End Sub
VBA Code:
Private a As Boolean

Private Sub btnPause_Click()
    a = False
End Sub

Private Sub btnReset_Click()
    a = False
    UserForm1.lblDisplay.Caption = "00:00:00"
End Sub

Private Sub btnStart_Click()
    a = True
    Do While a
    
        UserForm1.lblDisplay.Caption = Format(DateAdd("s", 1, UserForm1.lblDisplay.Caption), "hh:mm:ss")
        Wait = 1
        Start = Timer
        While Timer < Start + Wait
            DoEvents
        Wend
    Loop
End Sub

Private Sub UserForm_Initialize()
    'Maximizes to screen size
    With Application
        .WindowState = xlMaximized
        Zoom = Int(.Width / Me.Width * 100)
        Width = .Width
        Height = .Height
    End With
End Sub
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Write 00:00.00 in A1 cell. Save and close the workbook.

In your workbook_open event add something like this:
VBA Code:
Private Sub Workbook_Open()
    UserForm1.Show
    UserForm1.lblDisplay.Caption = Range("A1").Value
End Sub
Then in your while loop also update A1 cell value:
VBA Code:
    Do While a
 
        UserForm1.lblDisplay.Caption = Format(DateAdd("s", 1, UserForm1.lblDisplay.Caption), "hh:mm:ss")
        Range("A1").Value = UserForm1.lblDisplay.Caption
        Wait = 1
        Start = Timer
        While Timer < Start + Wait
            DoEvents
        Wend
    Loop
And in workbook_close event you may like to reset the timer information in A1:
VBA Code:
Private Sub Workbook_Close()
    Range("A1").Value = "00:00:00"
End Sub

The main idea here is to store the elapsed time information in a cell and retrive the time from this cell. This is just a concept idea. You may have to play around with it.
 
Upvote 0
Thank you for the response. Unfortunately, I wanted to use the userform and not the spreadsheet. Also, when the user clicks the reset button, it doesn't update the cell. Thank you again.
 
Upvote 0
Then, I have no idea. Maybe you should wait for other suggestions.

EDIT: You can fwrite to another file like a text file if you don't want to use the spreadsheet. But you must keep the time record in some way.
 
Upvote 0

Forum statistics

Threads
1,223,757
Messages
6,174,327
Members
452,555
Latest member
colc007

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