Try:
Sub Date_Macro()
Dim DateAsk As String
Dim DateWithin6Months As Date
DateAsk = InputBox("Enter the Date the document was extracted in (MM-DD-YYYY) Format")
If Not IsDate(DateAsk) Then
DateAsk = InputBox("Re-Enter: Must be in date format (MM-DD-YYYY)")
End If
DateWithin6Months = DateAdd("m", -6, DateAsk)
DateWithin6Months = Format(DateWithin6Months, "mm/dd/yyyy")
MsgBox DateWithin6Months 'this can be removed. Here for testing purposes
End Sub
- Changed DateAsk to string to allow for error check
- added in error check
- edited DateWithin6Months to reference DateAsk not Date
Bookmarks