Hi Everyone!
first, I'm not good at creating VBAs from scratch. I usually get ideas from the forums then putting everything together to build a macro. I am trying to create a timer macro using Active X Control Button so that when I click "Start", the button will automatically switch to "Stop". at the same time, the start and stop time will be displayed in two different column like the example below.
[/IMG]
furthermore, I need the timers to show and align with the given intervals indicated.
here are the codes I have so far
Option Explicit
Private Sub StartTimer_Click()
If StartTimer.Caption = "Start" Then
StartTimer.Caption = "Stop"
-----'if its possible to incorporate the start timer in this line
Else
StartTimer.Caption = "Start"
-----'if its possible to incorporate the stop timer in this line
End If
End Sub
and here are some codes that I'm trying to put together with the active X.
Option Explicit
Public Sub StartTimer()
timer.Cells(StartRowOffset(timer.[StartTitles]), timer.[StartTitles].Column).Value = Format(Now(), "HH:MM:SS AM/PM")
End Sub
Public Sub EndTimer()
timer.Cells(StartRowOffset(timer.[EndTitles]), timer.[EndTitles].Column).Value = Format(Now(), "HH:MM:SS AM/PM")
End Sub
Public Sub ClearTimer()
timer.Range(timer.[StartTitles].Offset(1, 0), timer.[EndTitles].Offset(StartRowOffset(timer.[EndTitles]), 0)).Clear
End Sub
Private Function StartRowOffset(rStart As Range) As Long
Dim startPoint As Range
Dim currentRows As Long
On Error GoTo err_h
StartRowOffset = timer.[StartTitles].Row + extendRangeDownLast(rStart).Rows.Count
exit_proc:
Exit Function
err_h:
StartRowOffset = 10 '0
End Function
'Sub test()
' MsgBox StartRowOffset
'End Sub
note: credit to codematic for the format and codes above.
first, I'm not good at creating VBAs from scratch. I usually get ideas from the forums then putting everything together to build a macro. I am trying to create a timer macro using Active X Control Button so that when I click "Start", the button will automatically switch to "Stop". at the same time, the start and stop time will be displayed in two different column like the example below.

furthermore, I need the timers to show and align with the given intervals indicated.
here are the codes I have so far
Option Explicit
Private Sub StartTimer_Click()
If StartTimer.Caption = "Start" Then
StartTimer.Caption = "Stop"
-----'if its possible to incorporate the start timer in this line
Else
StartTimer.Caption = "Start"
-----'if its possible to incorporate the stop timer in this line
End If
End Sub
and here are some codes that I'm trying to put together with the active X.
Option Explicit
Public Sub StartTimer()
timer.Cells(StartRowOffset(timer.[StartTitles]), timer.[StartTitles].Column).Value = Format(Now(), "HH:MM:SS AM/PM")
End Sub
Public Sub EndTimer()
timer.Cells(StartRowOffset(timer.[EndTitles]), timer.[EndTitles].Column).Value = Format(Now(), "HH:MM:SS AM/PM")
End Sub
Public Sub ClearTimer()
timer.Range(timer.[StartTitles].Offset(1, 0), timer.[EndTitles].Offset(StartRowOffset(timer.[EndTitles]), 0)).Clear
End Sub
Private Function StartRowOffset(rStart As Range) As Long
Dim startPoint As Range
Dim currentRows As Long
On Error GoTo err_h
StartRowOffset = timer.[StartTitles].Row + extendRangeDownLast(rStart).Rows.Count
exit_proc:
Exit Function
err_h:
StartRowOffset = 10 '0
End Function
'Sub test()
' MsgBox StartRowOffset
'End Sub
note: credit to codematic for the format and codes above.