Multiple if statements based on dates

StillUnderstanding

Board Regular
Joined
Jan 30, 2021
Messages
80
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hello,

I wonder if someone might be able to helps me with an IF statement. I am looking to do the following:-

If the time between 2 dates is less than 14 then return the word "Yes", If the time between 2 dates is more than 14.01 then return the word "No", If the time is less than 14 from today then return "Not Included"

Having some issues trying to work this out and hope someone might be able to help?
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Hi
less than 14 days, or time. If it is time do you have date and time combined together ?, Can you show an example please
 
Upvote 0
When you're saying "If the time is less than 14 from today", are you asking "if the 1st date is less than 14 days from today" or "if the last date is less than 14 days from today" and should this overwrite the Yes and No conditions ?
 
Upvote 0
So below is a likely output based:-
Date 1Date 2TodayIs the date less than 14 days?
01/05/2022​
11/05/2022​
29/06/2022​
Less than 14 days
01/05/2022​
19/05/2022​
29/06/2022​
More than 14 days
17/05/2022​
18/05/2022​
29/06/2022​
Under 14 days from today

So the example above asking if Date 1 is within 14 days of Date 2, if so then return "Less than 14 days" if more then return More than 14 days. The third variable comes in if todays date is less than 14 days from Date 1, if so then return "under 14 days from today"

I hope that helps?
 
Upvote 0
Try this :

=IF(SUM(TODAY()-A3)<14,"Under 14 days from today",IF(SUM(B3-A3)>14,"More than 14 days","Less than 14 days"))

Assuming Date 1 = Column A and Date 2 = Column B
 
Upvote 0
Try this :

=IF(SUM(TODAY()-A3)<14,"Under 14 days from today",IF(SUM(B3-A3)>14,"More than 14 days","Less than 14 days"))

Assuming Date 1 = Column A and Date 2 = Column B
Thanks @WillUK this works but I think I am now missing a match at the start. Here is the code that works without matching anything.

VBA Code:
=IF(SUM(TODAY()-'Sheet1'!I33)<14,"Under 14 Days from Today",IF(SUM(H33-'Sheet1'!I33)>14,"More than 14 Days",IF(SUM(H33-'Sheet1'!I33)<14,"less than 14 days from column A")))

What would I need to do if I wanted to match an email address in both sheets first, so if the emails match then return the data, if they don't match then return "Blank"

So if the email address was on column AM in sheet 1 and AN in the sheet that the code would be in.
 
Upvote 0
What would I need to do if I wanted to match an email address in both sheets first, so if the emails match then return the data, if they don't match then return "Blank"

So if the email address was on column AM in sheet 1 and AN in the sheet that the code would be in.

Where will be sheet 2 email?
 
Upvote 0
So on Sheet 1 it would be column “am” and on the sheet with the code it would be column “an”. The sheet with the second email would be Sheet 2.
So you want formula in column AN of sheet1

in Which column would be the email in sheet2?
 
Upvote 0
@Sufiyan97 Sorry I seen how I have added confusion.

The code as it is now looks like this:-

=IF(SUM(TODAY()-Sheet2!A4)<14,"Under 14 Days from Today",IF(SUM(B4-Sheet2!A4)>14,"More than 14 Days",IF(SUM(B4-Sheet2!A4)<14,"less than 14 days from column A in sheet 2")))

Sheet 1 looks like this:-
1656529559227.png


And Sheet 2 looks like this:-
1656529531811.png


So using the above example I would be looking for the code to sit in column "D" of Sheet 1 and for it to check Sheet 2 for a matching email address and then compare the date to tell me if it fits in with one of the following:-

  • Under 14 Days from Today
  • More than 14 Days
  • Less than 14 days from column A in sheet 2
At the minute the code is not matching the email address first.

Thanks for all your help with this!
 
Upvote 0

Forum statistics

Threads
1,215,473
Messages
6,125,018
Members
449,203
Latest member
tungnmqn90

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