Need ideas for formula to display groups of data in certain format

Dman333

Board Regular
Joined
Sep 30, 2016
Messages
52
Office Version
  1. 365
Platform
  1. Windows
Hello All:

I'm looking for a formula that can go through a list of Items and Categories and then create a more readable output without having to list each item. Below I have Items and a category / bucket. I'd like to be able to have a formula that would show the results in the Desired Summary / Item #'s column like below. So instead of a list showing every number, it can display 1-3, 7, 17-20. There are a bunch of different formulas that do parts of this, I just can't figure out how to put them together so when you change an Item from Bucket A to Bucket B the Item #'s Summary will update.

Any help or ideas is greatly appreciated and thanks for the time.

Unique IdentifierCategoryDesired Summary
Item #BucketSummaryItem #'s
1ABucket A1-3, 7, 17-20
2ABucket B4-6, 8, 13
3ABucket C9-11
4BBucket D12, 14-16
5B
6B
7A
8B
9C
10C
11C
12D
13B
14D
15D
16D
17A
18A
19A
20A
 
[TR]
[TD]=IF(D2="","",SUBSTITUTE(TRIM(SUBSTITUTE(SUBSTITUTE(TRIM(CONCAT(IF(B$2:B$21=D2,IF(B$1:B$20<>D2,A$2:A$21,IF(B$3:B$22<>D2,A$2:A$21," ")),",")))," ","-"),","," "))," ",", "))[/TD]
[/TR]
Peter_SSs:
You have the winning solution. This works exactly the way I wanted. I'm going to take some time dissect this one as I'm getting a little lost in exactly how you are using spaces and commas to get the final format.

Thanks for your time.
Cheers
 
Upvote 0

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
You're welcome.

To help with understanding the space/comma issues I suggest selecting say cell E2 in my sample and use the 'Evaluate Formula' tool (on the Formulas ribbon tab and keep clicking 'Evaluate' until the Concat has been completed. You would see this

1612838125476.png


TRIM is then applied to remove any multiple spaces and then the remaining spaces are replaced (using SUBSTITUTE) with "-" which gives the number range parts like this

1612838250287.png


Then all the commas are replaced with spaces, TRIMed again and this time the remaining individual spaces replaced with ", " to give the final result.

1612838405125.png
 
Upvote 0
You're welcome.

To help with understanding the space/comma issues I suggest selecting say cell E2 in my sample and use the 'Evaluate Formula' tool (on the Formulas ribbon tab and keep clicking 'Evaluate' until the Concat has been completed. You would see this

View attachment 31600

TRIM is then applied to remove any multiple spaces and then the remaining spaces are replaced (using SUBSTITUTE) with "-" which gives the number range parts like this

View attachment 31601

Then all the commas are replaced with spaces, TRIMed again and this time the remaining individual spaces replaced with ", " to give the final result.

View attachment 31602
Thanks again for all your help with this. I've been using it and ran into a snag that I fear eliminates this option. As it turns out, there are occasions where the item # has to go into a different column now. If you delete any item in the list you can see what I mean. The items are always numbers. Can you think of any other way to get the same result with this new issue?
Thanks in advance for all your efforts.
Cheers
 
Upvote 0
Could you give us some sample data and expected results that demonstrates the new issue?
 
Upvote 0

Forum statistics

Threads
1,214,994
Messages
6,122,633
Members
449,092
Latest member
bsb1122

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