redspanna
Well-known Member
- Joined
- Jul 27, 2005
- Messages
- 1,602
- Office Version
- 365
- Platform
- Windows
Hi all
So, I have this code pasted into a worksheet that will 'force' any times entered to be shown as mm:ss
these times are then copied/pasted into the "Data" sheet and are displayed also as H:mm format.
However when I use these times as part of a UserForm instead of showing for example 05:26, I get times like 12:26 even though I have formatted the code in the UserForm to show the time as mm:ss like this
If I change this format to H:mm:ss I do get the correct value, for example 0:05:26
Any idea why this happens?
Thanks in advance
any ideas why this happens
So, I have this code pasted into a worksheet that will 'force' any times entered to be shown as mm:ss
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("F3:AE2000")) Is Nothing Then
If Target.Value < 0 Or Target.Value > 1 And Target.NumberFormat <> "h:mm" Then Exit Sub
Application.EnableEvents = False
Target.Value = Target.Value / 60
Target.NumberFormat = "mm:ss"
Application.EnableEvents = True
End If
End Sub
these times are then copied/pasted into the "Data" sheet and are displayed also as H:mm format.
However when I use these times as part of a UserForm instead of showing for example 05:26, I get times like 12:26 even though I have formatted the code in the UserForm to show the time as mm:ss like this
VBA Code:
Label39.Caption = Format(Worksheets("Data").Range("H1").Value, "mm:ss")
If I change this format to H:mm:ss I do get the correct value, for example 0:05:26
Any idea why this happens?
Thanks in advance
any ideas why this happens