Excel Formula: Insert a Specific Text After the Group of Texts

MrRajKumar

Active Member
Joined
Jan 29, 2008
Messages
291
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have the following data in A1:B7, The values in A2:B7 are in a single cell spill formula (dynamic array fill). The range will always be sorted by Group, so they return here in ascending order.

GroupNames
Group 1John
Group 1Steve
Group 1Boe
Group 2Jose
Group 2Lily
Group 2Robert

I would like to insert "Completed" after the every group. Output has shown below. Its OK, if I get the text 'Completed' either starting or ending of a group.
So whenever a new Group comes, should be added the text 'Completed'.

I can add VSTACK({"Group 1","Completed"},A2#) if it is only one group. I am stuck since more than one group.

Thank you all for your valuable time.

GroupNames
Group 1John
Group 1Steve
Group 1Boe
Group 1Completed
Group 2Jose
Group 2Lily
Group 2Robert
Group 2Completed
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
How about
Excel Formula:
=LET(u,UNIQUE(INDEX(A2#,,1)),SORTBY(VSTACK(A2#,CHOOSE({1,2},u,"Completed")),VSTACK(SEQUENCE(ROWS(A2#)),XMATCH(u,INDEX(A2#,,1),,-1)+0.5)))
 
Upvote 0
Solution
One more option:
Excel Formula:
=DROP(REDUCE("",UNIQUE(INDEX(A1#,,1)),LAMBDA(a,b,VSTACK(a,FILTER(A1#,INDEX(A1#,,1)=b),HSTACK(b,"Completed")))),3)
 
Upvote 0
How about
Excel Formula:
=LET(u,UNIQUE(INDEX(A2#,,1)),SORTBY(VSTACK(A2#,CHOOSE({1,2},u,"Completed")),VSTACK(SEQUENCE(ROWS(A2#)),XMATCH(u,INDEX(A2#,,1),,-1)+0.5)))

Thank you. It works. I used the following version,

=SORT(VSTACK(A2#,CHOOSE({1,2},UNIQUE(INDEX(A2#,,1)),"Completed")),{1,2})
 
Upvote 0
One more option:
Excel Formula:
=DROP(REDUCE("",UNIQUE(INDEX(A1#,,1)),LAMBDA(a,b,VSTACK(a,FILTER(A1#,INDEX(A1#,,1)=b),HSTACK(b,"Completed")))),3)

Thank you for your reply Cubist. This version doesn't give me correct result. Below are the result I got with this formula.

Group 1Boe
Group 1Completed
Group 2Jose
Group 2Lily
Group 2Robert
Group 2Completed
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0
Thank you for your reply Cubist. This version doesn't give me correct result. Below are the result I got with this formula.

Group 1Boe
Group 1Completed
Group 2Jose
Group 2Lily
Group 2Robert
Group 2Completed
Change the 3 to 1. I assumed the headers were part of the array.
 
Upvote 0

Forum statistics

Threads
1,224,816
Messages
6,181,143
Members
453,021
Latest member
Justyna P

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