INDEX Formula expected to error. Errors sometimes. Sometimes returns empty cell. Help from Formula expert needed.

DocAElstein

Banned user
Joined
May 24, 2014
Messages
1,336
<o:p></o:p>
<o:p> </o:p>
. Hi,<o:p></o:p>
. I have done my best to keep this short and to the point, and probably failed, sorry! . But I think, however, a formula expert could follow ( - I did at least answer half my question as I tried to clearly explain my problem!! )<o:p></o:p>
. I am having difficulty understanding part of a formula which I am using to develop a much larger formula. I can get over the problem, but without understanding what is going on it makes further developing and maintaining of the formula difficult. <o:p></o:p>
. Can someone explain, in detail if possible, what is actually “going on” here<o:p></o:p>
. I simplify the example greatly to demonstrate and emphasis I do not need a “solution” to get the formula to “work”. - I have that . I need to know exactly what is happening in the formula as it stands in it’s current shortened and simplified form. <o:p></o:p>
<o:p> </o:p>
………………………..<o:p></o:p>
<o:p> </o:p>
. In the following screenshot I am primarily interested in the Table J2:K6 as my input , and the row L2:R2 as my output. The output is the pulled out values in the K column for consecutive rows in the Input table if in that row the value in the J column is J2 <o:p></o:p>
<o:p> </o:p>
<o:p> </o:p>
<o:p> </o:p>
<o:p> </o:p>
Using Excel 2007<o:p></o:p>
[Table="width:, class:grid"][tr][td]-[/td][td]
I
[/td][td]
J
[/td][td]
K
[/td][td]
L
[/td][td]
M
[/td][td]
N
[/td][td]
O
[/td][td]
P
[/td][td]
Q
[/td][td]
R
[/td][/tr][tr][td]
1
[/td][td]INDEX(__,r/c)[/td][td][/td][td][/td][td]c=Row(J:L) = 1[/td][td]c=Row(J:M) = 2[/td][td]c=Row(J:N) = 3[/td][td]c=Row(J:O) = 4[/td][td]c=Row(J:P) = 5[/td][td]c=Row(J:Q) = 6[/td][td]c=Row(J:R) = 7[/td][/tr][tr][td]
2
[/td][td]r = 1[/td][td]J2[/td][td]K2[/td][td]K2[/td][td]K3[/td][td][/td][td]K5[/td][td][/td][td]
#BEZUG!​
[/td][td]
#BEZUG!​
[/td][/tr][tr][td]
3
[/td][td]r = 2[/td][td]J2[/td][td]K3[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr][tr][td]
4
[/td][td]r = 3[/td][td]OLE[/td][td]K4[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr][tr][td]
5
[/td][td]r = 4[/td][td]J2[/td][td]K5[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr][tr][td]
6
[/td][td]r = 5[/td][td]WigyWam[/td][td]K6[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr][tr][td]
7
[/td][td]r = 6[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr][tr][td]
8
[/td][td]r = 7[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]<o:p></o:p>

[/table]
[Table="width:, class:grid"][tr][td]MrExcelExample[/td][/tr][/table]<o:p></o:p>
<o:p> </o:p>
<o:p> </o:p>
<o:p> </o:p>
. I achieve this with the following formula which is “CSE” entered in cell L2 and is then dragged across through to cell R2.<o:p></o:p>
<o:p> </o:p>
=INDEX( IF($J2=$J2:$J$6 , $K2:$K$6 , "") , COLUMNS($J:J) , 1 )<o:p></o:p>
<o:p> </o:p>
<o:p> </o:p>
. Full screen shot showing all formulas:<o:p></o:p>
<o:p> </o:p>
. <b>Excel 2007</b><table width="1" cellpadding="2.5px" rules="all" style=";background-color: #FFFFFF;border: 1px solid;border-collapse: collapse; border-color: #A6AAB6"><colgroup><col width="25px" style="background-color: #E0E0F0" /><col /><col /><col /><col /><col /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: #E0E0F0;text-align: center;color: #161120"><th></th><th>J</th><th>K</th><th>L</th><th>M</th><th>N</th><th>O</th><th>P</th><th>Q</th><th>R</th></tr></thead><tbody><tr ><td style="color: #161120;text-align: center;">2</td><td style=";">J2</td><td style=";">K2</td><td style="background-color: #F0F5E7;;">K2</td><td style="background-color: #F0F5E7;;">K3</td><td style="background-color: #F0F5E7;;"></td><td style="background-color: #F0F5E7;;">K5</td><td style="background-color: #F0F5E7;;"></td><td style="text-align: right;background-color: #F0F5E7;;">#BEZUG!</td><td style="text-align: right;background-color: #F0F5E7;;">#BEZUG!</td></tr><tr ><td style="color: #161120;text-align: center;">3</td><td style=";">J2</td><td style=";">K3</td><td style="text-align: right;background-color: #F0F5E7;;"></td><td style="text-align: right;background-color: #F0F5E7;;"></td><td style="text-align: right;background-color: #F0F5E7;;"></td><td style="text-align: right;background-color: #F0F5E7;;"></td><td style="text-align: right;background-color: #F0F5E7;;"></td><td style="text-align: right;background-color: #F0F5E7;;"></td><td style="text-align: right;background-color: #F0F5E7;;"></td></tr><tr ><td style="color: #161120;text-align: center;">4</td><td style=";">OLE</td><td style=";">K4</td><td style="text-align: right;background-color: #F0F5E7;;"></td><td style="text-align: right;background-color: #F0F5E7;;"></td><td style="text-align: right;background-color: #F0F5E7;;"></td><td style="text-align: right;background-color: #F0F5E7;;"></td><td style="text-align: right;background-color: #F0F5E7;;"></td><td style="text-align: right;background-color: #F0F5E7;;"></td><td style="text-align: right;background-color: #F0F5E7;;"></td></tr><tr ><td style="color: #161120;text-align: center;">5</td><td style=";">J2</td><td style=";">K5</td><td style="text-align: right;background-color: #F0F5E7;;"></td><td style="text-align: right;background-color: #F0F5E7;;"></td><td style="text-align: right;background-color: #F0F5E7;;"></td><td style="text-align: right;background-color: #F0F5E7;;"></td><td style="text-align: right;background-color: #F0F5E7;;"></td><td style="text-align: right;background-color: #F0F5E7;;"></td><td style="text-align: right;background-color: #F0F5E7;;"></td></tr><tr ><td style="color: #161120;text-align: center;">6</td><td style=";">WigyWam</td><td style=";">K6</td><td style="text-align: right;background-color: #F0F5E7;;"></td><td style="text-align: right;background-color: #F0F5E7;;"></td><td style="text-align: right;background-color: #F0F5E7;;"></td><td style="text-align: right;background-color: #F0F5E7;;"></td><td style="text-align: right;background-color: #F0F5E7;;"></td><td style="text-align: right;background-color: #F0F5E7;;"></td><td style="text-align: right;background-color: #F0F5E7;;"></td></tr></tbody></table><p style="width:8,4em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid #A6AAB6;border-top:none;text-align: center;background-color: #E0E0F0;color: #161120">MrExcelExample</p><br /><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: #FFFFFF" ><tr><td style="padding:6px" ><b>Array Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: #FFFFFF;border-collapse: collapse; border-color: #A6AAB6"><thead><tr style=" background-color: #E0E0F0;color: #161120"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">L2</th><td style="text-align:left">{=INDEX(<font color="Blue">IF(<font color="Red">$J2=$J2:$J$6,$K2:$K$6,""</font>),COLUMNS(<font color="Red">$J:J</font>),1</font>)}</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">M2</th><td style="text-align:left">{=INDEX(<font color="Blue">IF(<font color="Red">$J2=$J2:$J$6,$K2:$K$6,""</font>),COLUMNS(<font color="Red">$J:K</font>),1</font>)}</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">N2</th><td style="text-align:left">{=INDEX(<font color="Blue">IF(<font color="Red">$J2=$J2:$J$6,$K2:$K$6,""</font>),COLUMNS(<font color="Red">$J:L</font>),1</font>)}</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">O2</th><td style="text-align:left">{=INDEX(<font color="Blue">IF(<font color="Red">$J2=$J2:$J$6,$K2:$K$6,""</font>),COLUMNS(<font color="Red">$J:M</font>),1</font>)}</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">P2</th><td style="text-align:left">{=INDEX(<font color="Blue">IF(<font color="Red">$J2=$J2:$J$6,$K2:$K$6,""</font>),COLUMNS(<font color="Red">$J:N</font>),1</font>)}</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">Q2</th><td style="text-align:left">{=INDEX(<font color="Blue">IF(<font color="Red">$J2=$J2:$J$6,$K2:$K$6,""</font>),COLUMNS(<font color="Red">$J:O</font>),1</font>)}</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">R2</th><td style="text-align:left">{=INDEX(<font color="Blue">IF(<font color="Red">$J2=$J2:$J$6,$K2:$K$6,""</font>),COLUMNS(<font color="Red">$J:P</font>),1</font>)}</td></tr></tbody></table><b>Entered with Ctrl+Shift+Enter.</b> If entered correctly, Excel will surround with curly braces {}.<o:p></o:p>
<b>Note: Do not try and enter the {} manually yourself</b></td></tr></table><br /><o:p></o:p>
<o:p> </o:p>
<o:p> </o:p>
<o:p> </o:p>
. If for example I look at the formula from cell N2 in the formula bar, highlight my True/False conditioning bit $J2=$J2:$J$6 and hit F9 , I get my instant evaluation of that part of the Formula shown in the Formula Bar thus<o:p></o:p>
<o:p> </o:p>
=INDEX(IF({TRUE,TRUE,FALSE,TRUE,FALSE},$K2:$K$6,""),COLUMNS($J:L),1)<o:p></o:p>
<o:p> </o:p>
. Clearly ( or at least I thought!? ) My formula becomes <o:p></o:p>
<o:p> </o:p>
=INDEX("",COLUMNS($J:L),1), which I was expecting to error because of the “” argument for the look up Array in the first argument of the INDEX Function ( INDEX ( “” , 3 , 1 ) )<o:p></o:p>
<o:p> </o:p>
. Indeed this formula, and variations thereof, ( Array entered or not ) <o:p></o:p>
= INDEX("",COLUMNS($J:L),1) … etc.<o:p></o:p>
. do indeed error rather than returning an empty cell as was the case with my original formula<o:p></o:p>
<o:p> </o:p>
. Question <o:p></o:p>
. can anyone explain why my original formula returns an empty cell and not an error ?<o:p></o:p>
<o:p> </o:p>
……………………………………………<o:p></o:p>
<o:p> </o:p>
. Further. … I have good reasons in my massive formula I am developing to drag past column Q ( That is to say effectively “looking past WigyWam” row , even though nothing past there is of interest..Clearly as I go past Column Q my row index for the INDEX goes past the maximum dimension of 5 and so I expect an error again. This time I get the expected error!! So I thought I had it sussed!! :confused:<o:p>:stickouttounge:</o:p>
<o:p> </o:p>
Thanks<o:p></o:p>
Alan Elston<o:p></o:p>
<o:p> </o:p>
<o:p> </o:p>
P.s. 1. I drop of a file if it helps. (XL 2007) “_Concatenating a) 2007.xlsx”<o:p></o:p>
https://app.box.com/s/di2hyk051cdnpx04qg6sqv1eswnx524y<o:p></o:p>
P.s.2 I emphasize Again that Ihave a solution, so for anyone with a similar requirement popping by I show it here..<o:p></o:p>
<o:p> </o:p>
From XL 2007<o:p></o:p>
=IFERROR(INDEX(IF($J2=$J2:$J$6,$K2:$K$6,""),COLUMNS($J:J),1),"")<o:p></o:p>
For XL2003 or lower (and from XL 2007)<o:p></o:p>
=IF(ISERROR(INDEX(IF($J2=$J2:$J$6,$K2:$K$6,""),COLUMNS($J:J),1)),"",INDEX(IF($J2=$J2:$J$6,$K2:$K$6,""),COLUMNS($J:J),1))<o:p></o:p>
… again array entered in cell L2 and dragged across<o:p></o:p>
P.s.3 I realize I can remove the ;1 column index in all the above formulas for the INDEX and rely on the default 1, but it just helps me to keep track of what is going on<o:p></o:p>
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
How it does what? Make calculations? Sorry don't understand that question.


.. In a way you have sort of helped answer some of my question with your response in Post # 9
The array produced is the result of these formula:

IF(J2=J2,K2,"")
IF(J2=J3,K3,"")
IF(J2=J4,K4,"")
IF(J2=J5,K5,"")
IF(J2=J6,K6,"")

. It was one of my proposed explanations of how things are done or calculated in a CSE Formula, …. - that being that it does a row by row analysis. This explains then why one can write a simple String in the third argument rather than the alternative of a Range, as I had proposed. (The alternative of an Array would have some advantages if the returned value for a False would be wished to be different for different rows …. But I had been proposing that as a more “Syntaxly” correct looking form. Clearly if Excel is calculating row by row, then the form given in my very original formula right at the start of Post # 1 is clearly now seen to be “syntax” correct also.)….

. So Thanks for the effort. It has helped a bit.

Alan :)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,862
Messages
6,181,464
Members
453,044
Latest member
rgbenson1

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