Forum Discussion
Expiry date (12/31/202X) triggered by unknown start date (XX/XX/202X) of that year
After I've examined both PDFs and VBA code, I would like to suggest few correction are as follows.
Replace
Range("D1").value =Date
with
Range("D1").value =Format(Date, "mm/dd/yyyy")
N.B.
- You may pick any Date format which ever is suitable.
- Using Format with Date is a wise move otherwise it's an optional.
Next is assign formula to the variable,, current code has wrong syntax, better use this.
Expiry =Application.DATE(Year(D1),Month(D1),Day(D1)+15)
- This will add 15 days to the Date value the code is accessing for cell D1.
Please remember that the DATEVALUE is not an appropriate to use, since it convert the DATE if as TEXT into NUMBER.
**Please confirm through REPLY whether this works for not, if works then you may accept my post as Best Solution as well Like.
First reply didn't seem to post @ 0830 my time.
Received the following Run-time error '438' (see attachment "Error Msg.")
Also attached a worksheet Code 2 copy of the revised syntax/code as instructed.
If it matters, I'm using Windows 10, MS Office v.18.2008.12711.0, MS Excel Office Home and Student 2019.
Does it matter what date format I use? I personally use 17 Dec 2020, but for the spreadsheet, cell D1, I used 12/17/2020.
Thanks, ProTee
- Rajesh_SinhaDec 20, 2020Iron Contributor
Using FORMAT is an optional but is a good practice,, please share the WB with us and let me check it, to fix the error!