Edate based on 3 date variables

davids4500

New Member
Joined
Jan 14, 2023
Messages
33
Office Version
  1. 365
Platform
  1. Windows
Hi everybody..
I have an excel spreadsheet as attached.
three columns have dates A1 which is todays date, H3 is the second date and J3 is the third date.
I need a formula that applies these 3 criteria:- If J3 = 0, and H3 = zero then P3 =EDATE(A1, O3), but if J3 = 0 and H3 has a date then P3 = EDATE(H3, O3), but if J3 has a date (and H3 may also have a date) then P3 =EDATE(J3, O3)
 

Attachments

  • ScreenshotExcel 2024-09-17 153547.jpg
    ScreenshotExcel 2024-09-17 153547.jpg
    208.9 KB · Views: 5

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Thank you Phuoc...it works...however, if O3 has a zero, it gives a #VALUE! answer. How do i fix that?
0 (or even blank) in O3 can't cause that error message. Do you have a formula in column O ? Does that formula return "" under certain conditions (show us the formula).
What do you want to happen if it returns "" do you want it to use it as if it was zero ?
Ideally change the formula in O3 to return 0 not "" if that is what you want.
Or you could try something like this:
Excel Formula:
=LET(mths,N(O3),
     IF(J3>0,EDATE(J3,mths),IF(H3=0,EDATE($A$1,mths),EDATE(H3,mths))))
If that is not what you want bebo's formula is another option.
 
Upvote 0
0 (or even blank) in O3 can't cause that error message. Do you have a formula in column O ? Does that formula return "" under certain conditions (show us the formula).
What do you want to happen if it returns "" do you want it to use it as if it was zero ?
Ideally change the formula in O3 to return 0 not "" if that is what you want.
Or you could try something like this:
Excel Formula:
=LET(mths,N(O3),
     IF(J3>0,EDATE(J3,mths),IF(H3=0,EDATE($A$1,mths),EDATE(H3,mths))))
If that is not what you want bebo's formula is another option.
0 (or even blank) in O3 can't cause that error message. Do you have a formula in column O ? Does that formula return "" under certain conditions (show us the formula).
What do you want to happen if it returns "" do you want it to use it as if it was zero ?
Ideally change the formula in O3 to return 0 not "" if that is what you want.
Or you could try something like this:
Excel Formula:
=LET(mths,N(O3),
     IF(J3>0,EDATE(J3,mths),IF(H3=0,EDATE($A$1,mths),EDATE(H3,mths))))
If that is not what you want bebo's formula is another option.
 
Upvote 0
Hi Alex. Thak you for the formula. I have noticed that though the variables are the same, the result was different for several instances eg(for line 37 & 38) and lines (92-95). Can you please explain that. I checked to make sure the cells were formatted the same etc. Look forward to your reply. David
 

Attachments

  • MrExcelScreenshot 2024-09-20 083749.jpg
    MrExcelScreenshot 2024-09-20 083749.jpg
    182.8 KB · Views: 3
  • MrExcelScreenshot 2024-09-20 083749B.jpg
    MrExcelScreenshot 2024-09-20 083749B.jpg
    47.8 KB · Views: 3
Upvote 0
What happens is you change the formula to this:
Rich (BB code):
=LET(mths,ROUND(N(O3),0),
     IF(J3>0,EDATE(J3,mths),IF(H3=0,EDATE($A$1,mths),EDATE(H3,mths))))
 
Upvote 0

Forum statistics

Threads
1,221,539
Messages
6,160,412
Members
451,644
Latest member
hglymph

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top