I'm looking to find missing numbers within 1000s of numbers in the first column.
I came across this formula;
=SMALL(IF(ISNA(MATCH(ROW(A$1:A$30),A$1:A$30,0)),ROW(A$1:A$30)),ROW(A1))
which works, except there is a problem.
In the formula it is using row numbers 1 to 30 , as defined by A$1:A$30 for lookup value in the MATCH formula
MATCH(lookup_value, lookup_array, [match_type])
in my application, the number of rows is not always going to be the same. I need to be able to indicate the range of values of which I want it to be compared against. By defining the min and max
I intent to feed it well into thousands of set of numbers each with thousands of rows. So changing the lookup value by row range everytime is not going to be feasible.
I want it to be able to read this range with min and max defined in two other cells.
As such;
=SMALL(IF(ISNA(MATCH(*1 to 5000*,A$1:A$30,0)),ROW(A$1:A$30)),ROW(A1))
where 1 is in cell lets say E1 and 5000 is in cell E2
obviously this doesn't work, so i'm looking for an answer regarding on how to define a range of numbers with min and max in two other cells.
Use INDEX to return the correct range:
=SMALL(IF(ISNA(MATCH(ROW(INDEX(A:A,$E$1):INDEX(A:A,$E$2)),A:A,0)),ROW(INDEX(A:A,$E$1):INDEX(A:A,$E$2))),ROW(A1))
This is an array formula and must be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode.
I saw an solution where someone was using a range as the criteria for COUNTIF and while trying to understand it better I found some really odd things happening and hoping someone could explain to me what is going on. Here is the setup of the excel.
Name,,Name
Excitebike,,Excitebike
RC Pro Am,,Super Mario Brothers
Punch Out,,Duck Hunt
Super Mario Brothers
Duck Hunt
Hopefully you can use the above to copy and paste it in. In column A there is a list of names and in column C there is a list of some of the names. In cell E1 there is a formula:
=COUNTIF($C$2:C4,$A$2:$A$6)
Then in cell E2 there is the exact same formula.
=COUNTIF($C$2:C4,$A$2:$A$6)
Here is a screen shot so you can see the formulas are identical:
So cell E1 and E2 have the exact same formula but are giving me a different result. As you can see in the first screen shot cell E1 gives a result of 0 while E2 gives a result of 1. Then if I make cell E1 into an array formula it gives a result of 1.
Why would the exact same formula in two different cells give a different result and why when changing cell E1 to an array formula would it change the result? I am using Excel 2016.
UPDATED: Additional questions.
When passing in a array into COUNTIF does it check each element in the range against each element in the criteria or does it just check row in the range against the corresponding row in the criteria?
Even when I put them in the same order, I cannot get the COUNTIF to return a number greater then 1. I would expect if the first 3 match the COUNTIF should return 3 but it is returning 1 for me. Please see below:
While rows 2, 3 and 4 match it is still giving an answer of 1.
I was a little surprised this worked at all. Typically I've used the "criteria" as >4 or <10 etc. Nice to know you can do a string comparison at all.
When using CountIf outside of an array formula you're going to be getting a comparison of values in adjacent cells. Typically CountIF is looking for a single criteria, not a range. At least that's the way I've always used it. eg, first formula in the cell range compared to first cells in each of the cell ranges.
Try these two experiments. Copy Super Mario Brothers from the right column to the left column and the results are going to now show 1 and 1 in the two formulas. Put it back. Move the two cells you have formulas in down one row, and you should see the results go from 1 and 0 to 1 and 1. Move it one more cell lower and it changes the values again.
I'm not sure this is what you're trying to accomplish, but copy this into the formula at and then copy down 6 rows. =COUNTIF($A$2:A$6,C2)
I am restructuring a few datasets and need to retrieve a list of non-contiguous values in a row in Excel for Mac. There are cells with blank spaces that should be discarded, so the result is a horizontal list of the same values, without the blank cells in between them.
The values appear in blocks of 6 contiguous cells interspersed by varying amounts (multiples of 6!) of blank cells. Data is numeric, so >0 does the trick. I have tried adapting solutions found online, such as this one here, with no luck.
I had to do something similar by retrieving 1st to 10th occurrence of values separately, and was able to accomplish that after dumping hloookup, learning index+match and array formulas, and adjusting solutions found online for a similar problem with columns, like this.
This is how my solution to the retrieving the 2nd occurence in a row looks like:
=IFERROR(INDEX($FR5:$GT5,SMALL(IF($FR5:$GT5>0,COLUMN($FR5:$GT5)-COLUMN($FR5)+1,FALSE),2)),"9999")
where $FR5:$GT5 is the range from which I need to retrieve values, and 9999 is my code for missing values. Just thought I'd throw it there, someone with limited skills as myself might find it useful.
Any tips to help me move along? Preferably, I'd like to adapt my previous formula to resolve this issue. I tried but was unable to get rid of the blank cells. I am stuck! Thanks in advance.
It isn't entirely clear on whether you want to show the collated (sans blanks) values in a row or a column but I suspect from the combination of relative row/absolute column cell references that you want to start in a cell and fill right.
Your formula is very close to collecting the sequence of numbers while ignoring blanks and numbers less than or equal to zero. You just need to adjust the k paramter of the SMALL function (the 2 in your sample formula above).
If you put =COLUMN(A:A) in a cell and fill right you will receive a sequence of integers like 1, 2, 3, 4, etc. Similarly, if you put =ROW(1:1) in a cell and fill down you will again receive 1, 2, 3, 4, etc. One of these sub-formulas can be used to increase the k of your SMALL depending upon whether you want to fill your formula right to receive the returned values in a single row or fill down to receive the returned values in a single column. In this manner, filling right or down will get you the second, third, etc returns.
To receive your returned values in a row use this array formula,
=IFERROR(INDEX(5:5, SMALL(IF($FR5:$GT5>0, COLUMN($FR:$GT)), COLUMN(A:A))),"9999")
Fill right as necessary to catch all values. To receive your returned values in a column use this array formula,
=IFERROR(INDEX($5:$5, SMALL(IF(FR$5:GT$5>0, COLUMN(FR:GT)), ROW(1:1))),"9999")
Fill down as necessary to catch all values.
Array formulas need to be finalized with Ctrl+Shift+Enter↵. Once entered into the first cell correctly, they can be filled or copied down or right just like any other formula.
I've never been a fan of the maths acrobatics (e.g. COLUMN($FR5:$GT5)-COLUMN($FR5)+1) that your original formula uses to determine the column (or row) in that style of formula. I've pared it down substantially in the above equivalent formulas but they amount to the same thing.
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.
I'm trying to retrieve values from cells on the same row spaced 20 columns apart.
Right now I have put together the following formula to retrieve the values in the first five cells I am interested in:
={IF(OR(IF({1,2,3,4,5}*20+1<25,CHAR(MOD({1,2,3,4,5}*20+1,26)+64),CHAR(INT(({1,2,3,4,5}*20+1)/26)+64)&CHAR(MOD({1,2,3,4,5}*20+1,26)+64))&ROW()="OK"),"OK","N/G")}
The cells contain the results of calculation checks. The result if given as either "OK", "N/G" or "N/A". Right now I am interested in determining if even a single cell reports "OK", hence using the OR in the formula.
The problem is that whilst this gets the address of the cells correctly, they are returned as text. OR then does a text comparison on the addresses and the criteria and finds that none of the addresses are "OK"... which is logical, but not what I want.
I have tried using INDIRECT(), but that doesn't seem to work when it is in the form ={INDIRECT("A1","B2","C3")}. Could anybody suggest a way to change the text addresses to addresses which will correctly be interpreted by the formula?
I could write some vba code for this, but I'd like to use a formula solution if possible.
With a static stagger to the columns you want to examine, you can use MOD() to determine their ordinal position on the worksheet.
The formula in CE2 is =IF(SUMPRODUCT(($A2:$CC2=CE$1)*(MOD(COLUMN($A:$CC),20)=1)), "Yes", "No"). Fill right and down as necessary.