I am looking for a function in Excel-VBA that converts a user-input of the form "hhmm" in the input-cell to the form "hh:mm" and checks for pausibility.
Any solution is welcome...
CodePudding user response:
Something like this:
Dim InputText As String
Dim TextDate As String
Dim TrueDate As Date
InputText = "1749"
TextDate = Left(InputText, 2) & "\:" & Right(InputText, 2)
If IsDate(TextDate) Then
TrueDate = CDate(TextDate)
' TrueDate -> #17:49#
End If
Now, set the format of the cell holding the value to hh:nn
.