Formula To Identify If Cell Dates Occur Within 30 Days of Adjacent Cell Date

eagerexceler

New Member
Joined
Jan 10, 2017
Messages
36
Office Version
  1. 2016
Platform
  1. Windows
Hello y'all,

I've got a simple formula to identify if a date in W4 occurs within 30 days of a date within X4: =IF(W4+30>X4,"Readmission Present", "No Readmission").

I'm trying to expand the formula to have it include this date comparison for the next 24 rows. As in, also including IF(X4+30>Y4.... and so on, all the way to AU4. I know I can do this with a crazy nested formula, but I'm wondering if anyone has any insight into making this a simpler formula.

Thank you!
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Try using DATEVALUE(X4) (syntax?) in the formula to first convert the date... I'll play around and get back to you because I've done this before, but can't check atm.
 
Upvote 0
Try using DATEVALUE(X4) (syntax?) in the formula to first convert the date... I'll play around and get back to you because I've done this before, but can't check atm.
Sorry, mis-read your origninal post.... so you want to "roll" up the dates as the formula moves down the list?
 
Upvote 0
Sorry, mis-read your original post.... so you want to "roll" up the dates as the formula moves down the list?
Probably would be easier to attach a short example of your sheet, it's hard to do a formula just off your description. But generally you can also put a reference to the prior row's forumla inside the the next, so the date comparasion is building up as the formula is pulled down the list.
 
Upvote 0
Thanks for your reply. Yep, I'm essentially trying to see if I can roll the date comparison up in an easier way to identify if a unique number has an account with a date within a range of a date in an adjacent cell. I've attached a dummy mini-sheet. Hope this helps.

The other step I need to get to (which may require a seperate thread) is that if the date in a cell is within the specified range of 30 day of the adjacent cell date, I need to sum the value of the applicable cell in column S and roll it up into column AX.

Sorry for getting more complicated here!

Excel Nest If Date Within Another Date Example.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQARASATAUAVAWAX
1
2                         
312345678910111213141516171819202122232425330
4##-1Provider #2#BegEndIndCalcNameTot1Tot2ActAmtCatSLReCHExCY19MarProAd 1Ad 2Ad 3Ad 4Ad 5Ad 6Ad 7Ad 8Ad 9Ad 10Ad 11Ad 12Ad 13Ad 14Ad 15Ad 16Ad 17Ad 18Ad 19Ad 20Ad 21Ad 22Ad 23Ad 24Ad 25W/In 30?W/In 3?Ad Ex
511-11111/1/191/4/19I32xxxxxxxxxxxxxxxxxxxxx(blank)0018089.41ba1/1/2019                        #VALUE!#VALUE!
622-11221/1/191/4/19I391xxxxxxxxxxxxxxxxxxxxx(blank)0011151.21ba1/1/2019                        #VALUE!#VALUE!
733-11331/3/192/15/19I1xxxxxxxxxxxxxxxxxxxxx(blank)003511191ba1/3/2019                        #VALUE!#VALUE!
844-11441/4/191/11/19I558xxxxxxxxxxxxxxxxxxxxx(blank)0061251ba1/4/2019                        #VALUE!#VALUE!
955-11751/11/191/25/19I668xxxxxxxxxxxxxxxxxxxxx(blank)0013378.41ba1/11/20195/31/201912/20/2019                      #VALUE!#VALUE!
1055-21555/31/196/7/19I653xxxxxxxxxxxxxxxxxxxxx(blank)0037537.61ba1/11/20195/31/201912/20/2019                      #VALUE!#VALUE!
1155-316512/20/1912/23/19I280xxxxxxxxxxxxxxxxxxxxx(blank)0011252.51ba1/11/20195/31/201912/20/2019                      #VALUE!#VALUE!
Sheet2
Cell Formulas
RangeFormula
W5:AU11,W2:AU2W2=IFNA(IF($H2="I",VLOOKUP($A2&"-"&W$3,$B:$F,5,FALSE),""),"")
X3:AU3X3=W3+1
A5:A11A5=E5
B5:B11B5=IF($H5="I",$E5&"-"&COUNTIFS($E$5:$E5,$E5,$H$5:$H5,"I"),"OP")
AV5:AV11AV5=IF((OR(($W5+AV$3>$X5),$X5+AV$3>$Y5,$Y5+AV$3>$Z5,$Z5+AV$3>$AA5,$AA5+AV$3>$AB5,$AB5+AV$3>$AC5,$AC5+AV$3>$AD5,$AD5+AV$3>$AE5,$AE5+AV$3>$AF5,$AF5+AV$3>$AG5,$AG5+AV$3>$AH5,$AH5+AV$3>$AI5,$AI5+AV$3>$AJ5,$AJ5+AV$3>$AK5,$AK5+AV$3>$AL5,$AL5+AV$3>$AM5,$AM5+AV$3>$AN5,$AN5+AV$3>$AO5,$AO5+AV$3>$AP5,$AP5+AV$3>$AQ5,$AQ5+AV$3>$AR5,$AR5+AV$3>$AS5,$AS5+AV$3>$AT5,$AT5+AV$3>$AU5)),"Present", "No Present")
AW5:AW11AW5=IF(OR(($W5+AW$3>$X5),$X5+AW$3>$Y5,$Y5+AW$3>$Z5,$Z5+AW$3>$AA5,$AA5+AW$3>$AB5,$AB5+AW$3>$AC5,$AC5+AW$3>$AD5,$AD5+AW$3>$AE5,$AE5+AW$3>$AF5,$AF5+AW$3>$AG5,$AG5+AW$3>$AH5,$AH5+AW$3>$AI5,$AI5+AW$3>$AJ5,$AJ5+AW$3>$AK5,$AK5+AW$3>$AL5,$AL5+AW$3>$AM5,$AM5+AW$3>$AN5,$AN5+AW$3>$AO5,$AO5+AW$3>$AP5,$AP5+AW$3>$AQ5,$AQ5+AW$3>$AR5,$AR5+AW$3>$AS5,$AS5+AW$3>$AT5,$AT5+AW$3>$AU5),"Present", "Not Present")
 
Upvote 0
Thanks for your reply. Yep, I'm essentially trying to see if I can roll the date comparison up in an easier way to identify if a unique number has an account with a date within a range of a date in an adjacent cell. I've attached a dummy mini-sheet. Hope this helps.

The other step I need to get to (which may require a seperate thread) is that if the date in a cell is within the specified range of 30 day of the adjacent cell date, I need to sum the value of the applicable cell in column S and roll it up into column AX.

Sorry for getting more complicated here!
Thanks this helps, I'll try it out on my end, but it'll be a few hours before I can get back to you.
 
Upvote 0
Ok, so looking this over now in excel, it makes better sense what you were trying to explain, thanks for sharing the data/formulas. There's a few ways to go about this, but honestly I probably would have done something similar (and have so) in my time with a messy nested formula. So here's the options I can think of, learning from my headache ;-)

1) Keep the insanely nested formula like you did, but either add a AND to account for the next right cell <>"" or just shroud the whole formula in IFERROR(..... , "") so the VALUE isn't glaring at the end. This really doesn't address simplifying things like you asked, so it's really just cosmetic. Also cosmetic is your "in 3" or "in 30" doesn't match AV AW between rows 3 and 4... but that's typo probably.

2) The simplest answer is this: since you're doing the same thing over that range on each row, comparing the left to right dates with the 3 or 30, but in a single cell... Why not apply just that basic comparison formula, but auto-fill drag the formula over to the right so it floats (relative reference), and does the same check over the range for each neighboring columns?. So say in AV5 insert

=IFERROR(IF(W5+$AV$3>X5,"Present", "No Present"), "")

then drag that to the right to cover all the other comparisons.

You'll end up with No Present No Present No Present Present.... or blanks across that range

Then you just add another column to COUNTIF (using present as a criteria) or MATCH (for "present" which will stop at the first encountered Present moving left to right over the range) over that horizontal range for "Present", and it'll essentially capture result that you were going for in your messy nested formula.

3) Use VBA to do the comparisons for you in a loop over the W through AU. It would actually be a double loop, first across the row, then repeat on the next row. If it finds a "Present" situation, it'll exit that row's loop and insert Present in that cell. So no nested formula needed, but a bit of coding.

If it's your sheet and you control it, it's easier just to do 2) and avoid the headache of messy formulas altogether!
 
Upvote 0
I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

How about
Excel Formula:
=IF(SUMPRODUCT(--(IFERROR(($W5:$AT5+AV$3)>$X5:$AU5,0))),"Present","Not Present")
 
Upvote 0
Thanks Oddball, I appreciate your details in looking at this! I'm definitely still a beginner, so I'm getting to learn more here.

1. So the problem I'm running into with the crazy nested formula is that the formula isn't working after the comparison of column Z903 to column AA903 in a particular example that should work. Is this because there isn't anything populated in cell AA903? What could I use to fix this? Sorry, I didn't initially include this example in my dummy worksheet.

2. I like that this simplifies things, but I ultimately need to compare these dates using two date amounts (3 vs 30), so wouldn't this require me to add a bunch more columns?

3. I'm not quite able to do much VBA yet, so this might be too much of a headache for me right now.

Again, thank you for your help!!
 
Upvote 0

Forum statistics

Threads
1,223,884
Messages
6,175,175
Members
452,615
Latest member
bogeys2birdies

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