count unique comma separated values from a single cell in excel

azad092

Board Regular
Joined
Dec 31, 2019
Messages
198
Office Version
  1. 2007
Platform
  1. Windows
Age1Y-10Y11Y-20Y21Y-30Y31Y-40Y41Y-50Y51Y-60YAbove 60Y
1,5,14,20,30,45,410000000
i want to calculate different age stages using comma separated value formula but it not works properly
how i can do this...
1,5 should be count in 1Y-10Y , 20 should be count in 11Y-20,30 should be count in 21Y-30Y and 45,41 should be count in 41Y-45Y
 
w
your work is so great i impressed but what the magic in your file because the formula works in your file but i copy formula from your file and apply in the same file i does not work it looks like a text plz see the file imageView attachment 3059
i observed that we can not edit the formula to change the cell reference according to our need
 
Upvote 0

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Please Note:

Create an array formula that calculates a single result


This type of array formula can simplify a worksheet model by replacing several different formulas with a single array formula.
  1. Click the cell in which you want to enter the array formula.
  2. Enter the formula that you want to use.
    Array formulas use standard formula syntax. They all begin with an equal sign (=), and you can use any of the built-in Excel functions in your array formulas.
    For example, this formula calculates the total value of an array of stock prices and shares, and places the result in the cell next to "Total Value."
    An example of an array formula calculating a single result

    The formula first multiplies the shares (cells B2 – F2) by their prices (cells B3 – F3), and then adds those results to create a grand total of 35,525. This is an example of a single-cell array formula because the formula lives in just one cell.
  3. Press Ctrl+Shift+Enter.
    When you press Ctrl+Shift+Enter, Excel automatically inserts the formula between { } (a pair of opening and closing braces).

Refrence:

You have to put the following formula and then press the 3 keys at the same time: Control + Shift + Enter

=SUM(--ISNUMBER(SEARCH(","&ROW(INDIRECT(SUBSTITUTE(B$1,"-",":")))&",",","&$A2&",")))
 
Upvote 0
You can copy the example and paste in your excel sheet:

View attachment 3057

Again I remind you that it is an array formula.
You must put this in the cell B2

=SUM(--ISNUMBER(SEARCH(","&ROW(INDIRECT(SUBSTITUTE(B$1,"-",":")))&",",","&$A2&",")))

Edit the formula and press the Control+Shift+Enter keys
thanks a lot....your work is so great thanks again
 
Upvote 0
Im glad to help you. Thanks for the feedback.
 
Upvote 0
your work is so great i impressed but what the magic in your file because the formula works in your file but i copy formula from your file and apply in the same file i does not work it looks like a text plz see the file imageView attachment 3059
hi
dear i am still facing a little issue in this formula, when i add more then one same age values the formula count only one out of them so plz guide me about this issue... thanks
 

Attachments

  • agge.jpeg
    agge.jpeg
    14.9 KB · Views: 4
Upvote 0

Attachments

  • agge.jpeg
    agge.jpeg
    14.9 KB · Views: 6
Upvote 0
hi
i am still facing an issue in age formula when add two same ages in a cell the formula count only one value as you can see in the image so please guide me how i can solve this issue

The formula offered by Dante is what you asked for, meaning "count unique comma separated values from a single cell in excel"
Count unique value.
 
Upvote 0
The formula offered by Dante is what you asked for, meaning "count unique comma separated values from a single cell in excel"
Count unique v
The formula offered by Dante is what you asked for, meaning "count unique comma separated values from a single cell in excel"
Count unique value.
please see the image and try to understand what i wants to say exactly.. in simple words by this formula i can count different ages from a single cell according to their age range but when i enter two same ages like as 11,11 or 22,22 the formula take only one value form same ages instead of all values... if you understand please guide me thanks
 

Attachments

  • agge.jpeg
    agge.jpeg
    14.9 KB · Views: 5
Upvote 0
Could you structure your age ranges at the top like this (make sure they are numbers, not numbers stored as text) and then use this standard-entry formula, copied across and down? This also avoids the use of the volatile function INDIRECT.

Book1
ABCDEFGH
1Age1112131415161
210203040506099
31,5,14,20,30,45,412210200
41,2,3,4,89,15,22,23,99,24,25,26,274160002
511,11,41,52,79,900200112
622,22,400021000
Sheet4
Cell Formulas
RangeFormula
B3:H6B3=COUNT(1/(LOOKUP(0+MID(SUBSTITUTE($A3,",",REPT(" ",100)),ROW(INDEX($A:$A,1):INDEX($A:$A,LEN($A3)))*100-99,100),$B$1:$H$1)=B$1))
 
Last edited:
Upvote 0
Could you structure your age ranges at the top like this
If you really want/need to keep the ranges as they were before, you can still do it but the formula becomes somewhat longer.

Book1
ABCDEFGH
1Age1-1011-2021-3031-4041-5051-6061-99
21,5,14,20,30,45,412210200
31,2,3,4,89,15,22,23,99,24,25,26,274160002
411,11,41,52,79,900200112
522,22,400021000
Sheet5
Cell Formulas
RangeFormula
B2:H5B2=COUNT(1/(LOOKUP(0+MID(SUBSTITUTE($A2,",",REPT(" ",100)),ROW(INDEX($A:$A,1):INDEX($A:$A,LEN($A2)))*100-99,100),LEFT($B$1:$H$1,FIND("-",$B$1:$H$1)-1)+0)=LEFT(B$1,FIND("-",B$1)-1)+0))
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,011
Messages
6,122,680
Members
449,091
Latest member
peppernaut

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top