FryGirl
Well-known Member
- Joined
- Nov 11, 2008
- Messages
- 1,364
- Office Version
- 365
- 2016
- Platform
- Windows
Hello all,
I have this working on column F to convert the value entered into time. So, for example, if the user enters 210, it's converting it to 3:30.
This is working good, but two questions if I could.
1) Is this the most efficient way to do this?
2) What can I do to validate that a number was entered?
I have this working on column F to convert the value entered into time. So, for example, if the user enters 210, it's converting it to 3:30.
This is working good, but two questions if I could.
1) Is this the most efficient way to do this?
2) What can I do to validate that a number was entered?
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range: Set rng = Target.Parent.Range("F:F")
If Target.CountLarge > 1 Then Exit Sub
If Target.Row < 2 Then Exit Sub
If Intersect(Target, rng) Is Nothing Then Exit Sub
Dim x As Variant: x = Target.Value
With Application
.EnableEvents = False
.ScreenUpdating = False
.Undo
End With
Target.Value = x / 1440
Target.NumberFormat = "[h]:mm"
With Application
.EnableEvents = True
.ScreenUpdating = True
End With
End Sub