I'm trying to automatically update the date range on the top of my report in Excel based on the date range from data I download from a text database. In the below listed macro I get a Run-time error '13': Type mismatch on PEndDt = Right(PaidDateRange, 8)
.
I think the Date variable, PEndDt, does not like getting a String. But I've assigned strings to Date variables in other macros! I don't now how to fix this. Help please.
Sub test()
Dim PEndDt As Date
Dim PaidDateRange As String
PaidDateRange = "PAID DATE 1/01/13 - 9/31/13"
PEndDt = Right(PaidDateRange, 8)
Range("A1") = "Report thru " & Format(PEndDt, "Long Date")
End Sub
Answer
The problem is in the string.
9/31/13 is not a valid date.
9/31/2013 is also not a valid date.
No comments:
Post a Comment