Can I use index match within an IF statement?

69liz

Board Regular
Joined
May 28, 2004
Messages
78
I am using index match to look up a value (test score) based on the student selected. No problems, working fine.

Now I'd like the returned test score to be change according to the assignment selected.

I've got 2 ranges at the moment storing the test scores (and there may be more in future) and have set up radio buttons to select which range to read the result from based on the student name as the lookup value.

It's working if I have the test results showing in different cells...ie. 2 difference index match functions.

But I want the test result in the same cell.
I've tried using an IF statement but whilst it continues to work if the first option button is selected, I get FALSE if the second one is selected.

=IF(AU5=1,INDEX(U5:U13,MATCH(A5,A5:A30,0),IF(AU5=2,INDEX(AQ5:AQ18,MATCH(AF5,AF5:AF18,0)))))

Can anyone see the problem or select a better way?

Thanks

Liz
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Hi Liz,

May I ask why you have the match at all? It will always equate to 1. You are saying in the range A5:A30, how many cells in before the value matches that of A5.

Do you see what I mean? I dare say this will be contributing to the issue.

Also, if you are getting FALSE, then AU5 must equal something other than 2?

Cheers
JB
 
Upvote 0
Hi,
I was using match because I thought it was a more efficient way than using VLOOKUP.

AU5 either contains 1 or 2 as it is the linked cell from the radio option buttons.

However, it does work with Vlookup so maybe I will stick to that method :)
 
Last edited:
Upvote 0
Ok, I think I get where you're coming from, but both of those Match() functions will ALWAYS result in 1, so may as well be replaced with '1'. Presumably not though, as I don't think that's what you're aiming for, but:

MATCH(A5,A5:A30)

MATCH function returns an integer, equal to how far it has to go into your range before it finds the value.

You are saying the value is whatever is in A5, and the range is A5:A30, so no matter the configuration, this will always return 1, as the first cell in the range is A5, and of course it will always be equal to itself!

Same goes for MATCH(AQ5,AQ5:AQ18).

I think you need to post a screenshot of your sheet so we can get a visual on what you're trying to achieve.
 
Upvote 0
Unfortunately I don't seem to be able to post screenshots. Not sure why. I don't have permission apparently.

Anyway, I've got it working with Vlookup.

The value A5 would change in the final version. Here it was just used to test out the formula. A5 holds the students name and in the final version this will be different.
 
Upvote 0
ohhh, so 'A5' was more of a placemarker in the formula, which would eventually be something completely different to the cells address, and the cell value of A5?

If that's the case, you may want to use something more like a variable instead, like StudentName in italics. The A5,A5:A30 really threw me! :biggrin:

If you mean the value will change, but you are referring to the value of cell A5, then I still fear you may run into issues.

Glad you're sorted though!

Cheers
JB
 
Upvote 0
Thanks JB. Sorry for the confusion. I will see how it pans out. Thanks for the heads up about screenshots. Presumably the same for sharing actual Excel files.
Really appreciate you taking the time to help. Liz
 
Upvote 0

Forum statistics

Threads
1,213,527
Messages
6,114,150
Members
448,552
Latest member
WORKINGWITHNOLEADER

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