Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

IF statement and dates

0

I need a formula that will calculate dates. I need "IF" more than four years from "NOW" add 12 months, "IF" less than four years from "NOW" add 6 months

Answer
Discuss

Answers

0
Selected Answer

This formula will do what you want. In the attached workbook it is in the cell E7.

=EDATE($C7, IF(DATEDIF($C$2,$C7,"y")<4, 6, 12))

It is essential that the dates you enter are true dates, not texts that look like a date. Toward this end I didn't format the cells E7:E8 though it applies equally to column C. The above formula produces a number which represents a date, and that is the way it should be. Follow the instructions in the attached workbook to format the cells correctly so that they display a date you can read. Format cells in column C as "General" to see the number behind the date presently displayed.

Discuss

Discussion

Excellent! Thank you very much for your quick response!
ng1031 (rep: 2) Sep 19, '18 at 8:07 am
Hello Ng,
Glad I could help and thanks for your comment. Please remember to mark the answer as "Accepted".
Variatus (rep: 4889) Sep 19, '18 at 8:16 pm
This is my first question - what do I do to accept it?
ng1031 (rep: 2) Sep 20, '18 at 3:49 pm
You already found the solution: you selected an answer. Thank you.
Variatus (rep: 4889) Sep 20, '18 at 8:26 pm
Add to Discussion


Answer the Question

You must create an account to use the forum. Create an Account or Login