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

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.

Related

Extract numbers before any letter or special sign within cell content

I have the following Excel spreadsheet:
A B C
1 125Product 125
2 58968Brand 58968
3 74Category 74
4 6325Product 6325
5 2:2 2:
6 7489Category458 7489Bra
7 29:Brand 29
8
In Column A I have contents consisting of numbers, letters or special characters.
In Column B I want to extract all numbers before any letter or special character; therefore, I use the following formula:
=LEFT(A2,SUM(LEN(A2)-LEN(SUBSTITUTE(A2,{"0","1","2","3","4","5","6","7","8","9"},""))))
This formula works for all values except for the values in Cell A5 and A6.
I guess the issue is that in this cell - instead of all the other values - there is a another number after the letter/special character.
What do I need to change in my formula to only extract the numbers before any letter or special character?
Formula used in B1:
=LEFT(A1,MATCH(FALSE,ISNUMBER(MID(A1,ROW($A$1:INDEX(A:A,LEN(A1))),1)*1),0)-1)
Confirm through Ctrl+Shift+Enter
If you don't want to enter as array, use:
=LEFT(A1,MATCH(FALSE,INDEX(ISNUMBER(MID(A1,ROW($A$1:INDEX(A:A,LEN(A1))),1)*1),0),0)-1)

Excel horizontal list to columns

I am looking to format some data. To make it more easy I use an example with simple numbers.
Sheet 1 ('S1'):
A1 10
A2 14
A3 23
A4 12
A5 64
A6 32
.... etc
It is a long list(vertical) of 600 values
Now I want in Sheet 2('S2'):
To show it as:
S1!A1 S1!A2 S1!A3 S1!A4 S1!A5 S1!A6
S1!A7 S1!A8 S1!A9 S1!A10 S1!A11 S1!A12
S1!A13 S1!A14 S1!A15 S1!A16 S1!A17 S1!A18
References to the cells in the other sheet.
I have tried to transpose them but I cannot find a modifier to set an amount of columns used. i.e. I would get 1 row with all my data. I want only the first 6 in row, next 6 in next row, next 6... etc.
Thanks for any help/feedback given.
Put this in the upper left cell desired:
=INDEX(Sheet1!$A:$A,(ROW(1:1)-1)*6+COLUMN(A:A))
Then copy/drag over 6 columns and down till you finish the list
Sheet1

Formula to count each individual digit in a cell per column in Excel

I have a list of numbers like below. And I need to know how many of each number are in each cell per column.
My List
1
2
3
4
10
11
12
13
14
21
22
23
24
I need to know how many times 1 occurs throughout the whole list, including double digit numbers, and I need to do this for each number 0-9. The reason I don't just count them is because I have a total of 1,400 numbers that I need to break down. I have tried =COUNTIF but unfortunately it sees numbers such as 22 and ONE number, when I need it to tell me that there are 2, 2s. Is there a way? Thanks!
With your data in A2:A15 and the digit to count in B2 you can use following array formula (confirmed with Ctrl+Shift+Enter):
=SUM(LEN(A2:A15)-LEN(SUBSTITUTE(A2:A15,B2,"")))
This would be a way of doing it:-
=SUM(LEN(A$1:A$10)-LEN(SUBSTITUTE(A$1:A$10,"1","")))
and the same for "2", "3" etc. or put digits 0-9 in a range of cells starting at (say) B1 and enter this in C1 and pull down:-
=SUM(LEN(A$1:A$10)-LEN(SUBSTITUTE(A$1:A$10,B1,"")))
Is an array formula and must be entered with CtrlShiftEnter
To count 1's, use something like:
=SUMPRODUCT(LEN(A2:A14)-LEN(SUBSTITUTE(A2:A14,"1","")))
You can count any digit or character or substring this way.
If you're only ever considering up to double-digit numbers, as you appear to suggest:
=SUMPRODUCT(0+(MID(A$1:A$10,{1,2},1)="1"))
Or, more dynamically, with e.g. 1 in B1:
=SUMPRODUCT(0+(MID(A$1:A$10,{1,2},1)=""&B1))
and copied down.
Regards

excel exclude a certain value from mode average

I'm looking for a formula that can find the Mode Average from a range of cells but exclude the value 14 from the range
example
A1 =26
A2 =14
A3 =14
A4 =14
A5 =26
A6 =3
A7 =16
A8 =16
A9 =26
Result would be:26 and not 14
Array formulas to the rescue:
=MODE(IF(A1:A6 <> 14,A1:A6))
Enter it via Ctrl + Shft + Enter
Not very elegant, but it works:
=(SUM(C3:C11)-COUNTIF(C3:C11,14)*14)/(COUNT(C3:C11)-COUNTIF(C3:C11,14))
c3:c11 is the range I am looking at on my test sheet.
I am basically looking for the sum of all values in the considered range, subtract 14 times the occurence of the number 14 from this sum and then divide the result by the total number of cells minus the occurences of 14 again. The whole thing will look much nicer, if you have the luxury of another cell that could serve as the "14-counter".
Edit: I overlooked the word "mode" in the question. This answer will only compute the average ...

Extract numbers from excel table

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.

Resources