Hi Team,
I have an ActiveX VB code to track time & end time, but the problem is that the ActiveX buttons keep resizing on click, this happens when the file is projected or the laptop is docked or undocked (change in resolution causes resizing, a Microsoft bug). Therefore I used the same VB coding for a form control button, everything works fine expect I am not able to enable or disable the start button & end button in sequence, which was possible initially with an ActiveX command button.
Active X code
Private Sub btnStart_Click()
ActiveSheet.Unprotect ""
Cells(Rows.Count, 3).End(xlUp).Offset(1) = Date
Cells(Rows.Count, 4).End(xlUp).Offset(1) = Now
Cells(Rows.Count, 4).End(xlUp).NumberFormat = "hh:mm:ss"
Cells(Rows.Count, 6).End(xlUp).Offset(1) = Environ("username")
Me.btnStart.Enabled = False
Me.btnStop.Enabled = True
ActiveSheet.Protect ""
End Sub
Private Sub btnStop_Click()
ActiveSheet.Unprotect ""
Cells(Rows.Count, 5).End(xlUp).Offset(1) = Now
Cells(Rows.Count, 5).End(xlUp).NumberFormat = "hh:mm:ss"
Me.btnStart.Enabled = True
Me.btnStop.Enabled = False
ActiveSheet.Protect ""
End Sub
Form Control button code
Sub Button5_Click()
ActiveSheet.Unprotect ""
Cells(Rows.Count, 3).End(xlUp).Offset(1) = Date
Cells(Rows.Count, 4).End(xlUp).Offset(1) = Now
Cells(Rows.Count, 4).End(xlUp).NumberFormat = "hh:mm:ss"
Cells(Rows.Count, 6).End(xlUp).Offset(1) = Environ("username")
ActiveSheet.Buttons("Button 5").Enabled = False
ActiveSheet.Buttons("Button 6").Enabled = True
ActiveSheet.Protect ""
End Sub
Sub Button6_Click()
ActiveSheet.Unprotect ""
Cells(Rows.Count, 5).End(xlUp).Offset(1) = Now
Cells(Rows.Count, 5).End(xlUp).NumberFormat = "hh:mm:ss"
ActiveSheet.Buttons("Button 5").Enabled = True
ActiveSheet.Buttons("Button 6").Enabled = False
ActiveSheet.Protect ""
End Sub
Please help me with the form control button coding; where the user should be able to click the start & end button in sequence, I am aware that the grey shading on the buttons won't work for a form control button.
Thanks in advance
Bookmarks