Extract numbers from excel table - excel

I have a Excel table with 5 columns filled with numbers, for e.g.
A1 B1 C1 D1 E1
4 12 23 37 41
1 4 19 25 45
4 20 25 31 44
I want to find the exact place (ROW,COLUMN) for each number.
In K1:
=COUNTIF($A$1:$E$3,H1)
where for e.g. H1=4 the result is 3
In (L1,M1,N1):
=SMALL(IF($A$1:$E$3=$H$1,ROW($A$1:$E$3)-ROW($A$1)+1),COLUMNS($L1:L1))
with Ctrl-Shift-Enter and the result is L1=1,M1=2,N1=3
Now I want to find a formula which show me the COLUMN number. If I use in (L2,M2,N2)
=SMALL(IF($A$1:$E$3=$H$1,COLUMN($A$1:$E$3)-COLUMN($A$1)+1),COLUMNS($L2:L2))
with Ctrl-Shift-Enter I have as result L2=1,M2=1,N2=2 which is not that I want. The order must be L2=1,M2=2,N2=1.
I have stuck with this. I use office 2007.

You could use the results you got from the rows to get the columns maybe?
=MATCH($H$1,INDEX($A$1:$E$3,L1,0),0)
In L2, filled through to M2 gives you the results you are expecting. Note that this formula works only if the number you're looking for (here 4) appears only once in any given row.

Related

Lookup using multiple columns and values

I have a sheet filled with data like below:
Gender MS Age Value
Male Married 21 1
22 2
23 3
24 4
Male Single 21 5
22 6
23 7
24 8
Female Married 21 9
22 10
23 11
24 12
Now there's this other sheet where the user will only be inputting the column "Gender", "MS", and "Age" values and the excel formula should be fetching the associated factor. Please help me with one such formula.
For e.g. If the user puts Male, Single and 23, the formula should return 7.
Here is an example on your sample data:
Formula in G4:
=INDEX(D1:D13,MATCH(1,(ROW(C1:C13)>=MATCH(1,(A1:A13=G1)*(B1:B13=G2),0))*(C1:C13=G3),0))
Enter through CtrlShiftEnter
You can use an array formula for this. I am assuming the blank data under Gender and MS are filled in.
=INDEX(Sheet1!A:D,MATCH(1,(Sheet2!A2=Sheet1!A:A)*(Sheet2!B2=Sheet1!B:B)*(Sheet2!C2=Sheet1!C:C),0),4)
After entering the formula, don't press enter! It is Ctrl+Shift+Enter to make this an array formula.
The formula given compares the values in cells A2, B2 and C2 of Sheet2 with the data held in columns A to D of Sheet1, and outputs the value of the fourth column of the appropriate row.

Make formula for list of row names independent from entire column and first row

I have the following Excel spreadsheet:
A B C D E F G H
1 Q1 Q2 Q3 Q4 Search criteria: 60 Asset 2
2 Asset 1 15 85 90 70 Asset 3
3 Asset 2 40 80 45 60 Asset 3
4 Asset 3 30 60 55 60 Asset 5
5 Asset 4 12 72 25 15
6 Asset 5 60 48 27 98
7
In Cells A1:E6 I have different assets with their performance from quarter Q1-Q4.
In Column H I list all assets that match the search criteria in Cell G1.
In this case the search criteria is 60 which can be found in the Cells A1:E6 for the Assets 2, 3 and 5.
For creating the list I use the formula from here:
=INDEX(A:A,SMALL(IF($B$2:$E$6=$G$1,ROW($B$2:$E$6)),ROW(1:1)))
All this works fine so far.
Now when I move the Cells A1:E6 in the sheet for example to D9:H14 the array formula keeps only working if it still refers to A:A and ROW(1:1) which might be a problem if the user decides to delete ROW(1:1). Therefore, I tried to modify the formula to:
=INDEX($D$9:$D$14,SMALL(IF($E$10:$H$14=$J$10,ROW($E$10:$H$14)),ROW($D$9:$H$9)))
However, with this modification I get #NUM! error.
Do you have any idea if it is possible to make the array formula independent from A:A and ROW(1:1) so it refers only to the Cells A1:E6 and automatically moves when the those cells are moved?
If you use excel 2013 or later then you can use following formula.
=IFERROR(INDEX($D$10:$D$14,AGGREGATE(15,6,ROW($1:$5)/($E$10:$H$14=$J$10),ROW(1:1))),"")
You can limit A:A to A1:A6 so that it would adjust as necessary when you move it. Your formula should thus be now
=INDEX(A1:A6,SMALL(IF($B$2:$E$6=$G$1,ROW($B$2:$E$6)),ROW(1:1)))
As for ROW(1:1), your top formula should always be ROW(1:1) and when you drag it down, then next formula should have ROW(2:2). When you move your top formula somewhere else and the ROW(1:1) changes to something like ROW(9:9) or anything, change it to ROW(1:1).
Please note that 'moving' your formula is different from 'dragging it down'.
EDIT:
So after you moved your data set, the top formula should now be:
=INDEX($D$9:$D$14,SMALL(IF($E$10:$H$14=$J$10,ROW($E$10:$H$14)),ROW(1:1)))
This is assuming that cell G1 (criteria) is also moved to J10.

Count the number of duplicates between rows excel

I’m wondering if someone can tell me how to count the number of duplicates that occur between 2 rows in excel? I’ve read lots of posts about counting duplicates in general, but it’s not quite what I’m looking for.
In the below example, I want to indicate how many numbers are repeated from the previous row. For example, Row 1 has 3 numbers repeating from Row 2. Row 2 has 1 number repeating from Row 3. Row 3 has 2 numbers repeating from Row 4. I don’t need to know what numbers or how many times each number was repeated, I just need to know how many occurrences of duplicates there are. Each number would be in its own cell. Is this even possible?
Row 1> 20 22 40 41 42 47
Row 2> 3 37 40 41 47 49
Row 3> 1 2 3 4 5 6
Row 4> 2 5 17 20 25 30
Use COUNTIF() wrapped in a SUM() as an array formula:
=SUM(COUNTIF(A2:F2,A1:F1))
Being an array formula it needs to be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode. If done correctly Excel will put {} around the formula.
Put the formula in the first desired output cell, Hit Ctrl-Shift-Enter. Then copy down.

Index/Match values from a column using a grid of a different length (Excel 2010)

I am trying to index match values from a long column to a grid of a different length. It looks like this
Word Number Column X Column Y Column Z
This 55 55 33 12
is 62 62 42 18
The 78 78 31 24
42
31
12
18
24
33
The grid (Column X,Y,Z) contains all the values from the Number Column. What I am trying to do is basically index the "Word" column, using a value from the "Number" Column, and looking it up in the value array of X Y Z.
Example (because this is confusing):
Input the Value 33 from the Number column, look for the value in the columns XYZ, and then return the Word "This".
Input the Value 18 from the number column, look for the value in columns XYZ, return the word "is"
etc...
Any help would be very much appreciated!
there is a quicker way and shorter formula to do this:
=IFERROR(INDEX(A:A,IFERROR(MATCH(B2,C:C,0),IFERROR(MATCH(B2,D:D,0),MATCH(B2,E:E,0))),1),"not found")
paste that into, any column really, into row 2 and drag down, it will return the words you require, if value not found it will return "not found"
Here is your spreadsheet starting at cell A1 (without your headers):
A B C D E
1 This 55 55 33 12
2 is 62 62 42 18
3 The 78 45 31 24
4 42
5 31
6 12
7 18
8 24
9 33
10
11 Input: 24
12 Output: The
Copy this into cell C10, and drag the formula across to cell E10:
=IF(ISERROR(IF(ISERROR(IF(ISERROR(MATCH($B$11,C1:C3,0)),"",CONCATENATE("A",MATCH($B$11,C1:C3,0)))),"",INDIRECT(IF(ISERROR(MATCH($B$11,C1:C3,0)),"",CONCATENATE("A",MATCH($B$11,C1:C3,0)))))),"",IF(ISERROR(IF(ISERROR(MATCH($B$11,C1:C3,0)),"",CONCATENATE("A",MATCH($B$11,C1:C3,0)))),"",INDIRECT(IF(ISERROR(MATCH($B$11,C1:C3,0)),"",CONCATENATE("A",MATCH($B$11,C1:C3,0))))))
Copy this to the "output" cell B12 and use cell B11 as your "input":
=CONCATENATE(C10,D10,E10)
VIOLA!!! You're done!
Proof:
The MATCH() function will look for your value in an array (the range). If it finds it, it returns the index of that array (indexed at 1), otherwise it throws an error. Be sure to set the 3rd argument to "0" so that it only looks for EXACT matches.
Paste this into C14:
=MATCH($B$11,C1:C3,0)
Next, we check if the MATCH() function did indeed throw an error. Paste this into C15:
=IF(ISERROR(C14),"",C14)
Now we have the row number of our matched value, so we will use the CONCATENATE() function to join it to our "word column", A, for use in the next step. Paste this into C16:
=CONCATENATE("A",C15)
Using that string from above, use the INDIRECT() function to turn it into an actual cell reference. Paste this into C17:
=INDIRECT(C16)
And finally, check if a legitimate cell reference was created. If so, return the word, otherwise return "". Paste this into C18:
=IF(ISERROR(C17),"",C17)
Lastly, drag the formulas from C14:C18 to E14:E18, and concatenate the results. The cells in row 18 should match the cells in row 10.
Hope this helps :)

Splitting numbers in a list and outputting a specific number from it

I want to use a list of 20 numbers all stored in the same cell and separated by spaces. Eg in A1 I have:
0 0 1 1 2 3 4 7 8 9 10 12 14 16 18 21 24 28 32 37
The code below (that I have in B1) will show how many numbers (or words, anything separated by spaces) are in cell A1:
=IF(LEN(TRIM(A1))=0,0,LEN(TRIM(A1))-LEN(SUBSTITUTE(A1," ",""))+1)
The output of B1 is 20.
I want to be able to input a number between 1 and 20 in cell A2 and have the output of B2 be the number corresponding to the value at that position in A1. For example input 19 in A2 would output 32 in B2.
I have several of these number sequences and as far as I can tell most of them can't be represented by a formula which would have been a lot easier. I could also put each number in a separate cell and use a large collection of IF() functions but that would be tedious with so many sequences.
I have tried SEARCH() with A1 data and B1 formula altered to:
1:0 2:0 3:1 4:1 5:2 6:3 7:4 8:7 9:8 10:9 11:10 12:12 13:14 14:16 15:18 16:21 17:24 18:28 19:32 20:37
=SEARCH(A2&":",A1)
Now when inputting 19 into cell A2 I get an output of 90 (the first character of the sequence being searched for is the 90th in the cell). I think this information might help me to output the number after the : which in this case is 32.
Is this possible?
As per your edit, you could use the 90 you got in MID().
=MID(MID(A1,SEARCH(A2&":",A1),SEARCH(A2+1&":",A1)-SEARCH(A2&":",A1)),FIND(":",MID(A1,SEARCH(A2&":",A1),SEARCH(A2+1&":",A1)-SEARCH(A2&":",A1)))+1,999)
The formula is a bit long, but would be shorter if you use another cell. For instance, if you put:
MID(A1,SEARCH(A2&":",A1),SEARCH(A2+1&":",A1)-SEARCH(A2&":",A1))
in C2, then the first formula will become
=MID(C2,FIND(":",C2)+1,len(C2))
A couple of alternatives.
Copy A1 to C1 (because B1 might be in the way) then apply Text to Columns on C1 with Space as the delimiter. In B1:
=INDEX(C1:V1,A2)
or,
in B1 (or B2 if you prefer) enter =CHOOSE(A2,X)
and in A3 enter =SUBSTITUTE(A1," ",",")
then replace X with the result of Copy and Paste Special Values on A3.

Resources