Combining cells with the same data but keeping some data separate

jarrodexcel

New Member
Joined
Dec 14, 2022
Messages
23
Office Version
  1. 365
Platform
  1. Windows
Good afternoon all.

Have a tricky goal to try and combine two rows with the same data, so merge it into one row of data. I will need a formula that can combine them as ill have lots of this data coming in.

As you can see below - A, B and C all share the same data and i need them merged into one, but D has different data and would need that to multiply by each other so the 5xABC etc and 3x ABC becomes 8xABC1111-1999.

Any help will go a long way !

Thank you so much


A B C D
John Doe
125522​
The big tree hotel, abc london5xABC1111-1999
John Doe
125522​
The big tree hotel, abc london3xABC1111-1999
 

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)
What happens if:
John Doe125522The big tree hotel, abc london5xDEF1111-1999
John Doe125522The big tree hotel, abc london3xABC1111-1999
 
Upvote 0
What happens if:
John Doe125522The big tree hotel, abc london5xDEF1111-1999
John Doe125522The big tree hotel, abc london3xABC1111-1999
That is another issue that i was going to raise after ! but in some cases it will be 5xDEF and 3xABC etc, so that will complicate the formula alot
 
Upvote 0
I'll give it a shot based on the question raised by @Flashbond :

Book1
ABCD
1John Doe125522The big tree hotel, abc london5xABC1111-1999
2John Doe125522The big tree hotel, abc london3xABC1111-1999
3John Doe125522The big tree hotel, abc london5xDEF1111-1999
4
5
6John Doe125522The big tree hotel, abc london8xABC1111-1999
7John Doe125522The big tree hotel, abc london5xDEF1111-1999
Sheet5
Cell Formulas
RangeFormula
A6:D7A6=LET(x,UNIQUE(HSTACK(A1:C3,TEXTAFTER(D1:D3,"x"))),HSTACK(TAKE(x,,3),BYROW(x,LAMBDA(y,SUM(--TEXTBEFORE(FILTER(D1:D3,MMULT(--(A1:C3=TAKE(y,,3)),{1;1;1})=3),"x"))))&"x"&DROP(x,,3)))
Dynamic array formulas.
 
Upvote 0
I'll give it a shot based on the question raised by @Flashbond :

Book1
ABCD
1John Doe125522The big tree hotel, abc london5xABC1111-1999
2John Doe125522The big tree hotel, abc london3xABC1111-1999
3John Doe125522The big tree hotel, abc london5xDEF1111-1999
4
5
6John Doe125522The big tree hotel, abc london8xABC1111-1999
7John Doe125522The big tree hotel, abc london5xDEF1111-1999
Sheet5
Cell Formulas
RangeFormula
A6:D7A6=LET(x,UNIQUE(HSTACK(A1:C3,TEXTAFTER(D1:D3,"x"))),HSTACK(TAKE(x,,3),BYROW(x,LAMBDA(y,SUM(--TEXTBEFORE(FILTER(D1:D3,MMULT(--(A1:C3=TAKE(y,,3)),{1;1;1})=3),"x"))))&"x"&DROP(x,,3)))
Dynamic array formulas.
Thank you for this ! Partially worked but this is my fault for not explaining fully, but if in cell C the data is the same i need those to all combine and then make the data in cell D combine as well, or become a list like 2xABC123,3xDEF123 etc.

I will post the full TABLE below so you can see, For example in C the ARKS will need to combine but their D data values will need to become a list in the same cell. The big tree hotel will need to combine as well, but as the D cell values both share the same ABC format they can become 8x.

I hope this makes better sense ?

A B C D
John DOE
1255887​
The office stop2xABC1234-40004
John DOE
1234466​
Two tree style shop2xABC1111-4004
John DOE
1255442​
Viewing Galary5x1155-1234tt
John DOE
1245222​
The Ark3xABC1234-9999
John DOE
1245222​
The Ark2x1234-9999_SS
John DOE
5222369​
Park Plaza7xABC1235-1994
John DOE
5478116​
Orange floor shop3xC111_2_4-SS
John DOE
5544899​
The top stop1xABC4004-1234
John DOE
1234455​
The big tree hotel, abc london6xABC1155-9999
John DOE
1234455​
The big tree hotel, abc london2xABC1155-9999
 
Upvote 0
So something along these lines then?

Book1
ABCD
1John DOE1255887The office stop2xABC1234-40004
2John DOE1234466Two tree style shop2xABC1111-4004
3John DOE1255442Viewing Galary5x1155-1234tt
4John DOE1245222The Ark3xABC1234-9999
5John DOE1245222The Ark2x1234-9999_SS
6John DOE5222369Park Plaza7xABC1235-1994
7John DOE5478116Orange floor shop3xC111_2_4-SS
8John DOE5544899The top stop1xABC4004-1234
9John DOE1234455The big tree hotel, abc london6xABC1155-9999
10John DOE1234455The big tree hotel, abc london2xABC1155-9999
11
12John DOE1255887The office stop2xABC1234-40004
13John DOE1234466Two tree style shop2xABC1111-4004
14John DOE1255442Viewing Galary5x1155-1234tt
15John DOE1245222The Ark3xABC1234-9999,2x1234-9999_SS
16John DOE5222369Park Plaza7xABC1235-1994
17John DOE5478116Orange floor shop3xC111_2_4-SS
18John DOE5544899The top stop1xABC4004-1234
19John DOE1234455The big tree hotel, abc london8xABC1155-9999
Sheet5
Cell Formulas
RangeFormula
A12:D19A12=LET(x,UNIQUE(A1:C10),HSTACK(x,BYROW(x,LAMBDA(y,LET(z,FILTER(D1:D10,MMULT(--(A1:C10=y),{1;1;1})=3),q,TEXTAFTER(z,"x"),TEXTJOIN(",",,MAP(UNIQUE(q),LAMBDA(r,SUM(--FILTER(TEXTBEFORE(z,"x"),q=r))&"x"&r))))))))
Dynamic array formulas.
 
Upvote 0
So something along these lines then?

Book1
ABCD
1John DOE1255887The office stop2xABC1234-40004
2John DOE1234466Two tree style shop2xABC1111-4004
3John DOE1255442Viewing Galary5x1155-1234tt
4John DOE1245222The Ark3xABC1234-9999
5John DOE1245222The Ark2x1234-9999_SS
6John DOE5222369Park Plaza7xABC1235-1994
7John DOE5478116Orange floor shop3xC111_2_4-SS
8John DOE5544899The top stop1xABC4004-1234
9John DOE1234455The big tree hotel, abc london6xABC1155-9999
10John DOE1234455The big tree hotel, abc london2xABC1155-9999
11
12John DOE1255887The office stop2xABC1234-40004
13John DOE1234466Two tree style shop2xABC1111-4004
14John DOE1255442Viewing Galary5x1155-1234tt
15John DOE1245222The Ark3xABC1234-9999,2x1234-9999_SS
16John DOE5222369Park Plaza7xABC1235-1994
17John DOE5478116Orange floor shop3xC111_2_4-SS
18John DOE5544899The top stop1xABC4004-1234
19John DOE1234455The big tree hotel, abc london8xABC1155-9999
Sheet5
Cell Formulas
RangeFormula
A12:D19A12=LET(x,UNIQUE(A1:C10),HSTACK(x,BYROW(x,LAMBDA(y,LET(z,FILTER(D1:D10,MMULT(--(A1:C10=y),{1;1;1})=3),q,TEXTAFTER(z,"x"),TEXTJOIN(",",,MAP(UNIQUE(q),LAMBDA(r,SUM(--FILTER(TEXTBEFORE(z,"x"),q=r))&"x"&r))))))))
Dynamic array formulas.

JvdV ! You are a hero ! i have just run it on excel and so far it seems to be working well. I am going to test it more over the next few days with more data coming in. But i think you might have just saved me hours of work a day !!!! You are such a legend ! Much LOVE <3
 
Upvote 0
Glad to hear it worked and saves time as well @jarrodexcel :)
Did have a quick question, if i had an extra cell that i needed to add in, the cell only contains additional information for the account and is not related to the 1xabc etc, how can i impliment that into the formula ?
 
Upvote 0

Forum statistics

Threads
1,215,101
Messages
6,123,095
Members
449,095
Latest member
gwguy

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