Count number of values within cell - excel

I am trying to count the number of values within a cell, in Excel. So far I have found plenty of ways to count the number of characters, regardless of whether they're a space, number, or letter. However, I would like to count the number of values in a list or a cell, like so:
Let's say in cell A1 I have the following sequence of values:
38 39 101 102 114 115 116 117 118 119 120 121 122 123 124 125
I would like for the cell to return 16, indicating that there are sixteen values in the cell.
Is there an easy way to do this with Excel?

If you have a known delimiter (what breaks up the values) and you don't have to test your data for whether it's a value or non-value then...
=LEN(A1)-LEN(SUBSTITUTE(A1,"[Your delimiter here]",""))+1
https://support.microsoft.com/en-us/kb/187667

Related

How do I find the largest numbers in a area, and then find the value of a number in the same row?

I cannot find a way to do this, is it possible (with excel functions or VBS)?
For example, these would be the initial values:
Number
Value
101
234
102
324
103
345
104
325
105
437
106
443
107
806
108
476
109
538
110
546
And after taking the three highest numbers, this would be the output:
Number
Value
107
806
110
546
109
538
The data is constantly updating, so that might cause some issues.
You can use FILTER in combination with LARGE function to achieve this:
Columns A and B represent sample data. Cell D2 can contain this formula:
=FILTER($A$2:$B$9,$B$2:$B$9>=LARGE($B$2:$B$9,3))
If data is constantly updating, better to have an Excel Table (I named TB_NumVal), so the range index get automatically updated.
In cell: J2:
=SORT(FILTER(SORT(TB_NumVal,2), (ROW(TB_NumVal[Number])-1)
> ROWS(TB_NumVal[Number])-3),2,-1)
Here is the output:
Explanation
We sort the data, then since we start on row 2 (row 1 is the header) we substract 1. So
ROW(TB_NumVal[Number])-1
will provide the row number starting from one.
ROWS(TB_NumVal[Number])
is the total number of rows, in our case 10.
Using a filter condition like this:
(ROW(TB_NumVal[Number])-1) > ROWS(TB_NumVal[Number])-3)
ensures only the last three row will be selected, then finally sorted the filtered result by value in descending order to match the result of the screenshot of the question.

Sorting numbers and strings together, where strings are numbers that can be followed by letters

I need to sort an Excel sheet which has a mixture of actual numbers and text containing numbers possibly followed by text.
For example if the following list was randomised, the end result should be:
54 <-- Actual number
55
56
57
57B <-- Number followed by a letter
57M <-- Yet another letter
58
58M
59
59M
60
60B
61
61M
62
62B
63
64
65
66
90
99
99A
100
100B
100B2
120
120B
I tried a million different ways. However, I can't work out a way to sort the sheet like this.
Is there a way to do this? Some sort of "humanised" sorting?
Add a helper column with the following formula:
=TEXT(IFERROR(LEFT(A1,MIN(IF(ISERROR(--MID(A1,SEQUENCE(LEN(A1)),1)),SEQUENCE(LEN(A1))))-1),A1),"000")&IFERROR(MID(A1,MIN(IF(ISERROR(--MID(A1,SEQUENCE(LEN(A1)),1)),SEQUENCE(LEN(A1)))),LEN(A1)),"")
Then sort on that.
Note: Change the "000" to the same number of digits as the largest number in the list.
Also if one does not have SEQUENCE substitute that part with ROW($ZZ$1:INDEX($ZZ:$ZZ,LEN(A1))) The formula would then also need to be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode.
Sorted on Column A:
Sorted on Column B:

How to compare 2 massive/huge/long lists and output any non matching results in one field

I have 2 massive columns filled with studentids
Column 1(SID) has 110,000 rows
Column 2(SID2) has 100,000 rows
How do I make a check of column 1 = column 2 or vice versa and then finally place it all in one field!
Current Results
SID SID2
45 45
142 142
237 218
238 441
410 410
440 442
452 237
452
Final Expected output
SID SID2 Check
45 45
142 142
237 218
238 441 238,441
410 410
440 442 440
452 237
452
238,441,440
As you can see, all the ids that dont match should be placed in one field so I can easily spot them rathen than looking though 100,000 rows
Looks like SolarMike answered assuming that the test is A2=B2, but I think you're asking if A2=[Anything in Column B] and if B2=[Anything in Column A]. Here's how I'd test that:
Column C:
=IFERROR(IF(MATCH(A2,B:B,0)>1,"",A2),A2)
Column D:
=IFERROR(IF(MATCH(B2,A:A,0)>1,"",B2),B2)
Column E (very crude, but effective):
=IF(AND(C2="",D2=""),"",CONCATENATE(C2,",",D2,","))
Now, your real problem is getting it all into one single cell. The only way I know how to do this is to use Concatenate, but it requires you to select EACH CELL individually.
=CONCATENATE(E2,E3,E4,E5,E6,E7,E8,E9,E10)
For 10000 rows, that doesn't seem feasible. Also, that output isn't very flexible, but I digress.
If you want to concatenate everything together in one cell, you have two options.
A) Use the VBA code here (it's pretty simple, this seems like a viable option): Concatenate Excel Ranges with VBA
B) Hope that you have Office 365 with TEXTJOIN() See Support article here.
You could use match() with iferror() and if():
=IF(IFERROR(MATCH(A1,B1,)>0,0),"ok",A1)
see:
To get both fields back use:
=IF(IFERROR(MATCH(A1,B1,)>0,0),"ok",A1)&" , "&IF(IFERROR(MATCH(A1,B1,)>0,0),"ok",B1)

Find all rows that contains 4 specific values?

I am using excel and I have a table of numbers with 6 columns from A to F and more than 1000 rows. For example, from my table,
4 17 37 38 47 53
8 43 54 55 56 60
4 18 21 25 38 57
15 25 37 38 58 59
4 16 19 20 27 43
18 32 47 50 54 56
i want to find if there is at least a row (it must be a row!) that contains the numbers 16 19 20 27. From this example, there is a match, but i don't know how to make a search or formula using four diferent numbers.
I feel like I need to use the match function but can't quite figure it out and I'm not sure about it. Does anyone know how to do this?
Thanks!
This should work:
=IF(AND(OR(A1=16,B1=16,C1=16,D1=16,E1=16,F1=16),OR(A1=19,B1=19,C1=19,D1=19,E1=19,F1=19),OR(A1=20,B1=20,C1=20,D1=20,E1=20,F1=20),OR(A1=27,B1=27,C1=27,D1=27,E1=27,F1=27)),"Yes","No")
Put it in a new column in the table. It will return a Yes if the row contains all 4 values, and a No otherwise. You can then filter the new column of Yes/No to search for a row with Yes
I put the four values you are seeking in I1:L1 and the array of data to be searched in A1:F#. Then in column G create a helper column that concatenates A:F into a delimited string. The formula in G1 is:
=":"&A1&":"&B1&":"&C1&":"&D1&":"&E1&":"&F1&":"
where I've used ":" for the delimiter (you can use any char that's not in your data).
The result in G1 is:
:4:17:37:38:47:53:
Now in H1 use this formula to search:
=NOT(ISERR(FIND(":"&$I$1&":",G1)*FIND(":"&$J$1&":",G1)*FIND(":"&$K$1&":",G1)*FIND(":"&$L$1&":",G1)))
Each FIND will return an INT if the value (with leading and trailing delimiters) is found and #VALUE! otherwise. So the product will be an INT if all values are found and #VALUE! otherwise. Wrapping the FINDs inside an ISERR makes the result prettier (TRUE/FALSE instead of #VALUE!), and inverting with NOT returns TRUE when all 4 values are found and FALSE otherwise.
Hope that helps.
Here's another way --- more elegant (no helper column). As before, I put the four values you are seeking in I1:L1 and the array of data to be searched in A1:F#. Then in column G use this ARRAY formula (CTRL-SHIFT-ENTER):
=NOT(OR(PRODUCT(A1:F1-$I$1)<>0,PRODUCT(A1:F1-$J$1)<>0,PRODUCT(A1:F1-$K$1)<>0,PRODUCT(A1:F1-$L$1)<>0))
Each PRODUCT term checks for the existence of one value and returns 0 when the value is found and a non-zero value otherwise. The results of each of the four PRODUCT terms is tested with <>0 which will return TRUE if a value is not found. Then OR with return TRUE if one or more values are not found and FALSE if all are found. That result is wrapped in a NOT so that the function result is TRUE when all four values are found.

Rounding in Excel Formula using complex conditions

Hi I need to round up the numbers (last 2 digits, no decimal) based on following conditions:
If from 0 to 64 should be 49
If from 65 – 89 set at 79
If from 90 – 129 set at 99
If from 130 – 164 set at 149
If from 165 – 189 set at 179
If from 190 – 229 set at 199
and so on until 989
Then:
If value is from 989 – 1099 set at 999
If value is from from 1100 – 1249 set at 1199
If value is from from 1250 – 1349 set at 1299
If value is from from 1350 – 1449 set at 1399
and so on until 5000
I would appreciate some info and help how to get a formula to work for this.
Thanks
Harmz
This is not really a rounding problem but more a conversion problem. because there seems to be no pattern to your number groups I don't think it is therefore something you can calculate and therefore you will have to do a lookup.
If you want to do it all in one formula you could use and array inside of a vlookup like the partial example below:
=VLOOKUP(C1,{0,49;65,79;90,99;130,149;165,179},2,TRUE)
Otherwise do it as a normal vlookup. All you need is a two column table table, the first column contains the lower bound of you ranges and the second column contains the value that you want it to be. The important thing is that the vlookup has the final parameter of true, this makes the vlookup find the nearest match.

Resources