using dates with index matches

bigdan

Well-known Member
Joined
Oct 5, 2009
Messages
846
Office Version
  1. 2013
Platform
  1. Windows
[TABLE="width: 500"]
<tbody>[TR]
[TD]2018-08[/TD]
[TD]1 Aug 18[/TD]
[TD]31 Aug 18[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2018-09[/TD]
[TD]1 Sep 18[/TD]
[TD]30 Sep 18[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2018-10[/TD]
[TD]1 Oct 18[/TD]
[TD]31 Oct 18[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]


Please see table above.

If I have a date like 9/15/18, I want it to run a search against this table, then return the corresponding result in col A, ie 2018-09. At the moment it's a looong list of if statements, which I'll fix. I would've expected an index match to fix it but when I do that, for some reason I get 2018-08 as the answer, instead of 2018-09. I've fixed that by entering
INDEX(A1:A3,MATCH(lookupfigure,C1:C3)+1)
But why do I have to type in the +1 ?
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Hi, If I understood correctly, why not just use TEXT function:


Book1
LM
29/15/20182018-09
Sheet4
Cell Formulas
RangeFormula
M2=TEXT(L2,"yyyy-mm")
 
Upvote 0
hahah didn't know about that one! thanks!

for future reference do you think you can explain the logic to me of the original question, just so I have a better understanding?
 
Upvote 0
Glad could help and thanks for the feedback!

for future reference do you think you can explain the logic to me of the original question, just so I have a better understanding?

MATCH is being used to check for the less than argument for [match_type] (default is 1) hence it is taking it back 1 step. If you would have used INDEX(A1:A3,MATCH(lookupfigure,B1:B3) it would have worked.
 
Upvote 0
Unless I'm misunderstanding you that's the formula I used. It was returning 1 month / 1 row prior to what I wanted which is why I added the +1 outside of the argument.
 
Upvote 0
In MATCH, you used C1:C3 which was end of month, I am using B1:B3 which is beginning of month. End of month will move the match back 1 row when match is less than 2nd row in this case hence 1 where as beginning of month will match less than row 3 and move to row 2 so you will not need to add +1 for this.
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

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