Help with multiple index matches with multiple if statements

andycreber

Board Regular
Joined
May 20, 2010
Messages
74
Office Version
  1. 2016
Hi, I'm trying to write a index match formula with 2 if statements.

So far my formula is

=IF(I3>H3,INDEX(zb!C:C,MATCH(1,(I3=zb!D:D)*(G3=zb!H:H)*(H3=zb!D:D),0)),(IF(H3>I3,INDEX(zb!C:C,MATCH(1,(H3=zb!D:D)*(G3=zb!H:H)*(H3=zb!D:D),0)))))

I want to return the data if I3 > H3 then match the data on sheet zb! column C if the value matches in either column I or H and matches data in column G against the data in column H on tab zb or if H3>I3 then do the same match

Many thanks in advance
 
If G3 and H3 are equal and you expect the formula to return a value, then the lookup values in G3 and H3 need to be on the same row in the zb worksheet in both columns D and H...then the corresponding value in column C of the zb worksheet will be returned. Have you confirmed that a match should be found? Can you provide an example?
 
Last edited:
Upvote 0

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Hi KRice, Your #5 post formula is working (thank you) when the values are different between between G3 & H3, but I have some instances where the values are the same, but the formula is not working when this is the case.
Hi, Column H is doing a sum if for any value with the same reference in column G as there can be multiple lines with the same reference in column G, this means the values between column H and I will be different, in the sense of column H will be a larger figure that column I. The reason for this is that sometimes there are multiple lines of data with the same reference in column G but different amounts and always I want to return the unique data from the zb tab in column C. I very much appreciate your help and sorry that it is confusing.
 
Upvote 0
Realize that I have never seen your worksheets. You have described one worksheet that has values in cells G3, H3, and I3. You have described another worksheet called "zb" that apparently has values in columns C, D, and H. Now, in your last post, you mention "same reference in column G", and you also mention column H and I. I cannot understand which sheet you are referring to, which is why I asked for an example...or anything that would clarify what your sheets look like and what you are trying to accomplish.

I explained in an earlier post what my formula does, but if that is not reliably working to return expected results, then I will need a clearer description of the problem. For example, in post #10, you said the formula is working, but...
but I have some instances where the values are the same, but the formula is not working when this is the case
What values are the same? Values found in columns D and H on the zb worksheet, or values in G3, H3, and I3 on the main sheet?

Please feel free to install the XL2BB add-in (see the link in my signature block) so that you can share an example, or post a table or image explaining what you have and what you want to match.
 
Upvote 0
1651726647160.png

z1 tab

1651726687555.png

zb tab

z1 with formaulas shown
1651726817932.png

z1 formulas cont...

Sorry I cannot upload the spreadsheet, hope the screenshots help The values can be the same in column H & I on the z1 tab

thank you




1651726857889.png
 
Upvote 0
In your first post, you indicated that a condition for the lookup to occur was that H3<I3 or I3<H3. In other words, H3 is not equal to I3. In your latest post, you have H3=I3, so the lookup will not occur because the first IF statement prevents that from happening. If this is indeed the issue and you want the lookup to occur even when H3=I3, then the logical check in the IF statement is not needed. As a side note, your previous post #10 mentions:
when the values are different between between G3 & H3
...which is referring to different columns and added to my confusion.

In your latest example, why would you expect an answer of "CAT" when CAT is not found in column C of the zb worksheet? If the match conditions are met, the formula will return a value only from column C of the zb worksheet. And if you do not care whether the columns H and I values on the z1 worksheet are equal, the answer returned would be TOM.

Book2
ABCDEFGH
1Jrnl.EntryJournal EntryAmountREFREF9
2DOGREX-1333.38DOGDOG
3DOGROVER-952.7DOGDOG
4CATTOM-2.86CATCAT
zb

The color coding shows which values in the z1 worksheet are searched for in selected columns of the zb worksheet (yellow and blue), and the column in the zb worksheet from which the value is taken and returned back to the formula in the z1 worksheet (green).
Book2
GHIJ
1REF9Negative for sumAmount for lookupZB MATCH BY REF & AMOUNT
2match to zb!Hmatch to zb!Dmatch to zb!Dreturn zb!C
3DOG-1333.38-1083.38REX
4DOG-1333.38250REX
5CAT-2.86-2.86TOM
z1
Cell Formulas
RangeFormula
J3:J5J3=IFERROR(INDEX(zb!$C$2:$C$10,MATCH(1,(G3=zb!$H$2:$H$10)*(((H3=zb!$D$2:$D$10)+(I3=zb!$D$2:$D$10))>0),0)),"no match")
 
Upvote 0
Hi,

Very sorry that I made the posts confusing, it's confusing for me, however I think your last formula re J3 is working, I would like to thank you very much for your help and patience with this query.
5 stars

have a great day
 
Upvote 0
That's good to hear, and I'm happy to help. To clarify, the latest formula completely ignores the relationship between values in columns H and I on the z1 worksheet. If the match criteria are not met, the INDEX/MATCH formula would return an error, so the entire formula is wrapped with an IFERROR function to return the result of "no match" in those cases.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,241
Members
452,622
Latest member
Laura_PinksBTHFT

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