I am trying to Lookup First column that is not empty and Return Corresponding Column Header In an Excel block of cells (I think called Array?)
For example:
In this picture, I want to look at all of the entries in B4:G9, and have my formula tell me the first column not to be empty is the column labeled as 1.
I have the following formula so far that seems to work, where I search each row, have each row return the column header that the first non-zero number shows up in, and then search the minimum of the returned column headers. However my actual data has more than 100 columns and 100 lines, so I am looking for something cleaner.
=MIN(
INDEX($B$3:$G$3,MATCH(TRUE,INDEX((B9:G9<>0),0),0)),
INDEX($B$3:$G$3,MATCH(TRUE,INDEX((B8:G8<>0),0),0)),
INDEX($B$3:$G$3,MATCH(TRUE,INDEX((B7:G7<>0),0),0)),
INDEX($B$3:$G$3,MATCH(TRUE,INDEX((B6:G6<>0),0),0)),
INDEX($B$3:$G$3,MATCH(TRUE,INDEX((B5:G5<>0),0),0)),
INDEX($B$3:$G$3,MATCH(TRUE,INDEX((B4:G4<>0),0),0)))
This formula should work for you, adjust the $B$4:$G$9 to match your actual dataset:
=INDEX($3:$3,1,MIN(IF($B$4:$G$9<>0,COLUMN($B$4:$G$9),COLUMNS($3:$3))))
Note: Depending on your version of Excel, you may have to confirm the formula with CtrlShiftEnter instead of just Enter. That will force the formula to be calculated as an array. You'll know you've done it correctly when the formula is surrounded by curly braces {formula} (the braces aren't put in manually, they're put in automatically upon successful array entry via CtrlShiftEnter)
I currently have this table on Excel:
I have applied this formula to the last column, so that it matches the first and the second column:
=IF(ISNA(MATCH(A6;$B$1:$B$6;0));"";INDEX($A$1:$B$6;MATCH(A6;$B$1:$B$6;0);2))
How can I get the third column into the upper formula so that it appears next to the matching names? (The idea is that the second and the third column are bonded)
Like this:
Minor change:
=IF(ISNA(MATCH(A6;$B$1:$B$6;0));"";INDEX($A$1:$C$6;MATCH(A6;$B$1:$B$6;0);{2,3}))
Example at different address:
=IF(ISNA(MATCH(A21,$B$21:$B$26,0)),"",INDEX($A$21:$C$26,MATCH(A21,$B$21:$B$26,0),{2,3}))
In current versions of Excel, the 2nd column will SPILL. In older versions, you may need to select both columns and enter it as an array formula with ctrl+shift+enter
Instead of INDEX/MATCH this can be accomplished with FILTER/COUNTIF:
=FILTER(B1:C6,COUNTIF(A1:A6,B1:B6))
It filters the given range B1:C6 where COUNTIF(A1:A6,B1:B6) equals 1.
PS If you would want the list of non-matching values you can use the same but you could add =0: =FILTER(B1:C6,COUNTIF(A1:A6,B1:B6)=0)
Office365 is required for this solution.
Currently having data like this for a specific column where it needs both numbers to be shown in a single cell separated by a slash
Is it possible to sum on such a column in Excel
to get the total at the bottom as 94/76
I tried using
=SUM(LEFT(I3,FIND("/",I3)-1):LEFT(I7,FIND("/",I7)-1))
Just to see if the part to the left of the slash would get added but it didn't work.
You could try IMSUM():
Formula in A6:
=SUBSTITUTE(SUBSTITUTE(IMSUM(SUBSTITUTE(A1:A4,"/","+")&"i"),"+","/"),"i","")
I guess this needs to be CSE-entered if one use an Excel version other than Microsoft365.
You can use this formula to sum the values to the left of the /,
=SUM(LEFT(A2:A5,FIND("/",A2:A5)-1)+0)
and this to sum the values to the right.
=SUM(MID(A2:A5,FIND("/",A2:A5)+1,255)+0)
You might need to enter these as array formulas using CTRL+SHIFT+ENTER and you'll probably need to alter the cell references.
So, based on my comment:
=Left(I3,2)*1
in one column and dragged down,
and
=RIGHT(I3,LEN(I3)-FIND("/",I3,1))*1
also dragged down, then in the following row two sums and finally
=J9&"/"&K9
Assuming the helper columns are J & K. The *1 is to turn text into a value.
You may try FILTERXML().
=SUM(FILTERXML("<t><s>"&SUBSTITUTE(A1:A4,"/","</s><s>")&"</s></t>","//s[1]")) & "/" & SUM(FILTERXML("<t><s>"&SUBSTITUTE(A1:A4,"/","</s><s>")&"</s></t>","//s[last()]"))
I am trying to compare the numbers in the Reachability Set column with the numbers in the same row of the Antecedent Set column and return the common values in the corresponding cells of the Intersection Set column.
Screenshot:
In Excel 2016 (but NOT Excel 2013), you can use the following array-entered formula.
=TEXTJOIN(",",TRUE,IFERROR(1/(1/(ISNUMBER(FIND(","&TRIM(MID(SUBSTITUTE(B2,",",REPT(" ",99)),seq_99,99))&",",","&A2&","))))*TRIM(MID(SUBSTITUTE(B2,",",REPT(" ",99)),seq_99,99)),""))
seq_99 is a Named Formula
Refers to: =IF(ROW(INDEX($1:$65535,1,1):INDEX($1:$65535,255,1))=1,1,(ROW(INDEX($1:$65535,1,1):INDEX($1:$65535,255,1))-1)*99)
To enter an array formula, after entering the formula in the cell, confirm by holding down ctrl + shift while hitting enter. If you do it correctly, Excel will place braces {...} around the formula.
Although you would think a VBA solution is required, it is actually quite simple to do this with formulae, provided you use a lot of helper columns. These can, of course, be hidden.
All you need is a number of columns equivalent to the maximum of the numerals in the sets, after each of the original columns of your table. For the example supplied, this would be 17 columns.
Here is a screenshot of the new table with the helper columns unhidden:
The follow formulae are entered into the top left cell of each coloured region and filled/copy-pasted/ctrl-entered into the rest of the cells.
Red Cells (entered into B2):
=IF(ISERROR(FIND(","&B$1&",",","&$A2&",")),0,1)
Green Cells (entered into T2):
=IF(ISERROR(FIND(","&T$1&",",","&$S2&",")),0,1)
Blue Cells (entered into AL2):
=IF(B2*T2,AL$1&",","")&AM2
And finally, the result entered into cell AK:
=LEFT(AL2,LEN(AL2)-1)
The formulae work by ensuring that all the numbers in the sets have a preceding, and trailing, comma so that they can be uniquely searched for.
Then it is a simple matter of constructing a grid for the sets where a 1 means the number exists in the set a 0 means it doesn't. Multiplying these two grids together results in the "intersection set".
Then it is a simple matter of reconstituting the result strings.
Caveat:
This solution won't work correctly if there are any spaces in the "Set" data. To overcome this you need to use the SUBSTITUTE() function.
I have been breaking my head over this formula for sometime now. I have found a solution which is too big and not so convenient to use every time. So can any Excel Expert give me a solution/suggestion?
Column A contains 150 values. Column D to R contains a table in which I need to look up the values in A one by one. I want to return address of all the cells that contains the value.
For example, Value in A2 is present in cells D5, E15, H10, R3 then my result should be D5,E15,H10,R13.
Please Note that some columns may not contain the value of A2, I do not want them displayed.
Here is the formula I have written:
=CONCATENATE(
IF(A2=IF(COUNTIF(D:D,A2),VLOOKUP(A2,D:D,1,FALSE),""),ADDRESS(MATCH(A2,D:D,0),4,4),0),",",
IF(A2=IF(COUNTIF(E:E,A2),VLOOKUP(A2,E:E,1,FALSE),""),ADDRESS(MATCH(A2,E:E,0),5,4),0),",",
IF(A2=IF(COUNTIF(F:F,A2),VLOOKUP(A2,F:F,1,FALSE),""),ADDRESS(MATCH(A2,F:F,0),6,4),0),",",
IF(A2=IF(COUNTIF(G:G,A2),VLOOKUP(A2,G:G,1,FALSE),""),ADDRESS(MATCH(A2,G:G,0),7,4),0),",",
IF(A2=IF(COUNTIF(H:H,A2),VLOOKUP(A2,H:H,1,FALSE),""),ADDRESS(MATCH(A2,H:H,0),8,4),0),",",
IF(A2=IF(COUNTIF(I:I,A2),VLOOKUP(A2,I:I,1,FALSE),""),ADDRESS(MATCH(A2,I:I,0),9,4),0),",",
IF(A2=IF(COUNTIF(J:J,A2),VLOOKUP(A2,J:J,1,FALSE),""),ADDRESS(MATCH(A2,J:J,0),10,4),0),",",
IF(A2=IF(COUNTIF(K:K,A2),VLOOKUP(A2,K:K,1,FALSE),""),ADDRESS(MATCH(A2,K:K,0),11,4),0),",",
IF(A2=IF(COUNTIF(L:L,A2),VLOOKUP(A2,L:L,1,FALSE),""),ADDRESS(MATCH(A2,L:L,0),12,4),0),",",
IF(A2=IF(COUNTIF(M:M,A2),VLOOKUP(A2,M:M,1,FALSE),""),ADDRESS(MATCH(A2,M:M,0),13,4),0),",",
IF(A2=IF(COUNTIF(N:N,A2),VLOOKUP(A2,N:N,1,FALSE),""),ADDRESS(MATCH(A2,N:N,0),14,4),0),",",
IF(A2=IF(COUNTIF(O:O,A2),VLOOKUP(A2,O:O,1,FALSE),""),ADDRESS(MATCH(A2,O:O,0),15,4),0),",",
IF(A2=IF(COUNTIF(P:P,A2),VLOOKUP(A2,P:P,1,FALSE),""),ADDRESS(MATCH(A2,P:P,0),16,4),0),",",
IF(A2=IF(COUNTIF(Q:Q,A2),VLOOKUP(A2,Q:Q,1,FALSE),""),ADDRESS(MATCH(A2,Q:Q,0),17,4),0),",",
IF(A2=IF(COUNTIF(R:R,A2),VLOOKUP(A2,R:R,1,FALSE),""),ADDRESS(MATCH(A2,R:R,0),18,4),0))
As I said, this works but I am looking for a simpler and smaller formula.
Hint: Maybe using array can help?
Thanks in advance :)
What you are trying to accomplish is not a great fit for Excel formulas, but it can be done with a smaller, simpler formula dragged across 15 columns instead of 1 giant complicated formula that tries to do everything at once.
Assuming column A has 150 values (from A1 to A150), and there is a table going from D1 to R50...
Enter =S1&IFERROR(","&ADDRESS(MATCH($A1,D$1:D$50,0),COLUMN(D1)),"") into T1.
Drag the formula across to AH1.
Enter =RIGHT(AH1,LEN(AH1)-1) into AI1.
Select T1 to AI150 and press Ctrl-D.
Column AI1 will contain the results you are looking for.
How does this work?
The formula in T1 begins by taking the result of one cell to the left (which is blank). Then it concatenates this with the address of the first match in column D (prefixed by a comma). If there is no match, it just concatenates blank (""). As you drag this formula to the right, it keeps concatenating addresses as matches come up (or blank if there are none). When you get to the end, you will have looked for matches in all 15 column of your table.
The formula in AI1 just strips off the initial comma if there is one.