Suggest me out of 2 formulas which is more reliable

hsandeep

Well-known Member
Joined
Dec 6, 2008
Messages
1,226
Office Version
  1. 2010
Platform
  1. Windows
  2. Mobile
I needed a formula with the following logic:
Check if any of the cells in the range S1987:W1987 contains the value 1.
If true, identify the corresponding column (S, T, U, V, or W) that contains the value 1.
From that identified column, get the value from the range S2001:2015 where the row number matches the row in I2001:I2015 where the value equals the value in cell I67.
If none of the cells in S1987:W1987 contains 1, check if any of the cells in the range K1987:R1987 contains the value 1.
If true, identify the corresponding column (K, L, M, N, O, P, Q, or R) that contains the value 1.
From that identified column, get the value from the range K2001:K2015 where the row number matches the row in I2001:I2015 where the value equals the value in cell I67.
If neither of the above conditions are met, return 0.

I have 2 formulas for this:
First:
Excel Formula:
=IFERROR(IF(SUMPRODUCT((S1987:W1987=1)*(I2001:I2015=I67)*(S2001:W2015)), INDEX((S2001:W2015)*(I2001:I2015=I67), MATCH(1, (S1987:W1987=1)*(I2001:I2015=I67), 0)), IF(SUMPRODUCT((K1987:R1987=1)*(I2001:I2015=I67)*(K2001:K2015)), INDEX((K2001:K2015)*(I2001:I2015=I67), MATCH(1, (K1987:R1987=1)*(I2001:I2015=I67), 0)), 0)), 0)
Second:
Excel Formula:
=IFERROR(INDEX(S2001:W2015, MATCH(I67, I2001:I2015, 0), MATCH(1, S1987:W1987, 0)), IFERROR(INDEX(K2001:K2015, MATCH(I67, I2001:I2015, 0), MATCH(1, K1987:R1987, 0)), 0))

My query is: Which formula should I use based on reliability, functionality & to meet any 'unforeseen circumstances' leading to unwanted results?
 
Seems a bit of a strange requirement but if in the 2nd part you only want to return the value from Column K regardless of which column contains the 1 then try this version:
(added the >0 to the column match in blue)

Rich (BB code):
=IFERROR(
          INDEX(S2001:W2015, MATCH(B1988, I2001:I2015, 0), MATCH(1, S1987:W1987, 0)),
          IFERROR(
          INDEX(K2001:K2015, MATCH(B1988, I2001:I2015, 0), MATCH(1, K1987:R1987, 0)>0),
          0))
 
Upvote 0

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Seems a bit of a strange requirement but if in the 2nd part you only want to return the value from Column K regardless of which column contains the 1 then try this version:
(added the >0 to the column match in blue)

Rich (BB code):
=IFERROR(
          INDEX(S2001:W2015, MATCH(B1988, I2001:I2015, 0), MATCH(1, S1987:W1987, 0)),
          IFERROR(
          INDEX(K2001:K2015, MATCH(B1988, I2001:I2015, 0), MATCH(1, K1987:R1987, 0)>0),
          0))
I successfully got the correct formula
Excel Formula:
=IF(COUNTIF(S1987:W1987, 1) = 1, INDEX(S2001:W2015, MATCH(I67, I2001:I2015, 0), MATCH(1, S1987:W1987, 0)), IF(COUNTIF(K1987:R1987, 1) = 1, INDEX(K2001:K2015, MATCH(I67, I2001:I2015, 0)), 0))
Thanks a lot Alex for your time & efforts.:)
 
Upvote 0
Solution

Forum statistics

Threads
1,223,885
Messages
6,175,187
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