Hello All,
I'm not very familiar with creating my own functions but found this online and am trying to manipulate it to my own need. I recorded the formulas and then replaced the range address with "strInputDate" but I'm still getting an "invalid procedure call or argument". it stops at the first formula for month. Any clues?
I'm not very familiar with creating my own functions but found this online and am trying to manipulate it to my own need. I recorded the formulas and then replaced the range address with "strInputDate" but I'm still getting an "invalid procedure call or argument". it stops at the first formula for month. Any clues?
VBA Code:
Public Function getDate(strInputDate As String) As Date
'Variable Declaration
Dim iMonth As Integer
Dim iDay As Integer
Dim lYear As Long
'
'Get month
iMonth = Mid(strInputDate, InStr(":", strInputDate) + 1, InStr("/", strInputDate) - 1 - InStr(":", strInputDate))
'
'Get day
iDay = Mid(strInputDate, InStr("/", strInputDate) + 1, InStr("/", strInputDate, InStr("/", strInputDate) + 1) - InStr("/", strInputDate) - 1)
'Get year
If Len(Mid(strInputDate, InStr("/", strInputDate, InStr("/", strInputDate) + 1) + 1, 4)) = 2 Then
lYear = "20" & Mid(strInputDate, InStr("/", strInputDate, InStr("/", strInputDate) + 1) + 1, 4)
Else: iYear = Mid(strInputDate, InStr("/", strInputDate, InStr("/", strInputDate) + 1) + 1, 4)
End If
'Create a complete date and return the value
getDate = CDate(MonthName(iMonth) & "/" & iDay & "/" & lYear)
'
End Function