Nested If Statement dealing with dates between multiple date ranges

ljmexcel

New Member
Joined
Feb 15, 2023
Messages
3
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
Hi all, I'm hoping someone can help with this.
  • I have a 105,000 row spreadsheet with each row representing a 5 minute interval on a given date.
  • The date range spans a 12 month period.
  • As per the attached file 'bill date range, a bill is produced each month and this bill a date range from the 9th of the start month to the 8th of the end month.
  • For each date in each row, I want it to look through all bill start and end dates to return the bill month on column AF.
  • I have added this formula =IF(AND(O3>=$AG$3,O3<=$AH$3),$AF$3,0).
  • The formula above looks at the date in the row(O3 and checked that it is greater than or equal to the March Bill start Date and less that or equal to the March Bill end date and then returns 'Mar' as the bill month. It is only checking the March bill date ranges
  • I need to nest this formula so for each row, it looks through all the Bill start and end dates (e.g. Mar through to Jan) so it can identify the correct month.
  • I can't see to figure this out.
  • Would love some help if possible. Maybe there is a better way and how I have started does make sense.

Much appreciated - John
 

Attachments

  • bill date range.png
    bill date range.png
    12.7 KB · Views: 5

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Take your date and subtract 8 days. Then format as "mmm".
 
Upvote 0
Take your date and subtract 8 days. Then format as "mmm".
Thanks you for the response, but I don't quite understand it. If I pick one date (11/02/2022), it should be flagged as a march Bill because it falls in the March Bill date range of 8/2 - 9/3 2022.
Iff I apply the suggested solution I subtract 8 days from 11/2/22 which results in 3/2/22. If I format that as 'mmm' it returns Feb. The correct result should be Mar.
Note also that the start and end ranges will vary, use case from use case.
 
Upvote 0
hold on.. i'll post my worksheet. But they are in US Regional settings.
 
Upvote 0
How about this:
Don't worry about the calculated day for >=9 being the 1st of a month. It is just to get the month calculated, the day makes no difference in the final result.

Cell Formulas
RangeFormula
B17:B29B17=IF(DAY(A17)>=9,EOMONTH(A17,0)+1,A17)
C17:C29C17=IF(DAY(A17)>=9,EOMONTH(A17,0)+1,A17)
D17:D29D17=FORMULATEXT(C17)
E17:E29E17=A17
F17:F29F17=IF(DAY(A17)>=9,EOMONTH(A17,0)+1,A17)
G17:G29G17=F17
 
Upvote 0
Solution
And if you want to use only the text value of a month name then use
Excel Formula:
=TEXT(IF(DAY(A17)>=9,EOMONTH(A17,0)+1,A17),"mmm")

This difference in the two calculations is that I thought your months were going backward, not forward.
 
Upvote 0
Thank you SO much @awoohaw . Based on the ideas you gave me, I did this =IF(DAY(O3)>=$AD$3,EOMONTH(O3,0)+1,O3). AD3 is simply the starting date for each billing month
 
Upvote 0
Happy to help! Best wishes. Welcome to the forum.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

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