AliWood
New member
- Joined
- May 1, 2020
- Messages
- 7
- Reaction score
- 0
- Points
- 0
- Excel Version(s)
- Office365
I have a project which on many occasions takes a date from a worksheet cell and primes a textbox or label accordingly.
A common subroutine I use is my own VBA routine 'UsualFormat' (see below)which simply converts a date into a standard format.
I use my own routine because I would like (for good reasons) to allow the worksheet cell (and the corresponding form field)
Public Function Usualformat(Dvalue) As Variant
If IsEmpty(Dvalue) Or Dvalue = "" Then
Usualformat = ""
Else
Usualformat = Format$(CDate(Dvalue), "dd MMM yyyy HH:mm")
End If
End Function
Fine, you're thinking. But I would rather not have to do this, because (a) it is a programming overhead (b) when I am debugging the code, time is wasted watching it meander through the routine.
Surely there exists a 'standard' VBA or Excel function that achieves this aim? i.e. Copes with an empty argument.
Best wishes, Ali Wood
A common subroutine I use is my own VBA routine 'UsualFormat' (see below)which simply converts a date into a standard format.
I use my own routine because I would like (for good reasons) to allow the worksheet cell (and the corresponding form field)
quite often to be empty rather than requiring it to hold a date.
Public Function Usualformat(Dvalue) As Variant
If IsEmpty(Dvalue) Or Dvalue = "" Then
Usualformat = ""
Else
Usualformat = Format$(CDate(Dvalue), "dd MMM yyyy HH:mm")
End If
End Function
Fine, you're thinking. But I would rather not have to do this, because (a) it is a programming overhead (b) when I am debugging the code, time is wasted watching it meander through the routine.
Surely there exists a 'standard' VBA or Excel function that achieves this aim? i.e. Copes with an empty argument.
Best wishes, Ali Wood
Last edited: