How to produce concatenated cell drawing from a changing source range

d0rian

Active Member
Joined
May 30, 2015
Messages
313
Office Version
  1. 365
See image below. I have several groupings of stock symbols -- the group they belong to changes on a daily basis, so the GROUP value in column A will change regularly. I want a formula that will produce the values in cells E2, E3, and E4...in other words, I want all of the symbols in "Group 1" concatenated (with a double-space in between each)...any help? I can't just use the clunky formulas =A1&" "&A2&" "&A3, etc etc because the # of symbols in each Group (in column A) changes...so there won't always be 16 symbols in group 1, 9 in Group 2, and so on...the formula needs to dynamically adjust to produce concatenated values based on the # of symbols in each group...

960KStR.jpg
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
If you have the TEXTJOIN function available you can use this. It is an array formula so should be entered without the {} but confirmed with Ctrl+Shift+Enter, not just Enter. If confirmed correctly, Excel will insert the {}. The formula can then be copied down.

If you don't have TEXTJOIN then I would suggest a macro solution. Post back if you want/need that.

Excel Workbook
ABCDE
1GroupSym
21a1abcd
31b2e
41c3fgh
51d
62e
73f
83g
93h
10
Concat groups
 
Last edited:
Upvote 0
If you don't have TEXTJOIN then I would suggest a macro solution. Post back if you want/need that.
I'll post this user-defined function anyway. To implement ..
1. Right click the sheet name tab and choose "View Code".
2. In the Visual Basic window use the menu to Insert|Module
3. Copy and Paste the code below into the main right hand pane that opens at step 2.
4. Close the Visual Basic window.
5. Enter the formula as shown in the screen shot below and copy down.
6. Your workbook will need to be saved as a macro-enabled workbook (*.xlsm)

Code:
Function Symbols(rGroup As Range, sGroup As String, rSym As Range) As String
  Symbols = Join(Filter(Application.Transpose(Evaluate("if(" & rGroup.Address & "=" & sGroup & "," & rSym.Address & ",""@"")")), "@", False), "  ")
End Function

Excel Workbook
ABCDE
1GroupSym
21a1abcd
31b2e
41c3fgh
51d
62e
73f
83g
93h
10
Concat groups
 
Last edited:
Upvote 0
Thanks for the reply; I'm trying to stay away from Array formulas, since my sheet is rather bloated and speed is important and Arrays are dynamic / more resource-intensive...likewise, I'm not all that great with VBA, so would prefer an in-cell formulaic solution...does anything jump to mind, or from what I described will I probably have to use at least one of those things? (I'm using v2007, so don't have TEXTJOIN).
 
Last edited:
Upvote 0
.. or from what I described will I probably have to use at least one of those things?
I think you will.


(I'm using v2007, so don't have TEXTJOIN).
Then unless somebody come up with a better solution, I think you'll need the UDF. If you follow those steps I gave you it should be easy enough. :)

What might be the largest number of rows in a single group?

The only other thing I can think of with standard formulas is as below where the result for each group appears on the last row of the group rather than as a compact result table.

Excel Workbook
ABC
1GroupSym
21aa
31ba b
41ca b c
51da b c d
62ee
73ff
83gf g
93hf g h
Concat groups
 
Last edited:
Upvote 0
.. or if we turn it up the other way. Copy these formulas down (& perhaps hide column C).
You'd have to get the list of groups some other way but perhaps you already have that?

Excel Workbook
ABCDEF
1GroupSym
21aa b c d1a b c d
31bb c d2e
41cc d3f g h
51dd
62ee
73ff g h
83gg h
93hh
Concat groups (2)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,427
Messages
6,119,419
Members
448,895
Latest member
omarahmed1

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