Multiple text cells in one cell

Ron99

Active Member
Joined
Feb 10, 2010
Messages
347
Office Version
  1. 2016
Platform
  1. Windows
[TABLE="width: 144"]
<colgroup><col width="64" style="width: 48pt;" span="3"> <tbody>[TR]
[TD="width: 64, bgcolor: transparent"]Hello,
[/TD]
[TD="width: 64, bgcolor: transparent"][/TD]
[TD="width: 64, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, colspan: 3"]I have a below data, I need a formula to merge multiple cells in 1 cell, as shown below in the output formula
[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="bgcolor: #44546A"]P/N[/TD]
[TD="bgcolor: #44546A"]PO[/TD]
[TD="bgcolor: #44546A"]OUTPUT[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]A[/TD]
[TD="bgcolor: transparent, align: right"]123[/TD]
[TD="width: 64, bgcolor: transparent"]123
456
189
[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]A[/TD]
[TD="bgcolor: transparent, align: right"]456[/TD]
[TD="bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]A[/TD]
[TD="bgcolor: transparent, align: right"]189[/TD]
[TD="bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]B[/TD]
[TD="bgcolor: transparent, align: right"]89[/TD]
[TD="width: 64, bgcolor: transparent"]89
698
[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]B[/TD]
[TD="bgcolor: transparent, align: right"]698[/TD]
[TD="bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]C[/TD]
[TD="bgcolor: transparent, align: right"]852[/TD]
[TD="width: 64, bgcolor: transparent"]852
741
963
256
789
[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]C[/TD]
[TD="bgcolor: transparent, align: right"]741[/TD]
[TD="bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]C[/TD]
[TD="bgcolor: transparent, align: right"]963[/TD]
[TD="bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]C[/TD]
[TD="bgcolor: transparent, align: right"]256[/TD]
[TD="bgcolor: transparent"] [/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"]C[/TD]
[TD="bgcolor: transparent, align: right"]789[/TD]
[TD="bgcolor: transparent"]
[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
I do not know of a way to do what you asked for with my version of Excel (XL2010) using a formula. However, I did develop a macro that will do what you asked for...
Code:
[table="width: 500"]
[tr]
	[td]Sub CombinePOs()
  Dim Ar As Range
  Range("B2", Cells(Rows.Count, "B").End(xlUp)).Copy Range("C2")
  With Range("A2", Cells(Rows.Count, "A").End(xlUp))
    .Copy Range("D2")
    .Offset(, 3).Value = Evaluate("IF(" & .Address & "=" & .Offset(-1).Address & ",""""," & .Address & ")")
    For Each Ar In .Offset(, 3).SpecialCells(xlBlanks).Areas
      Ar(1).Offset(-1, -1) = Join(Application.Transpose(Ar(1).Offset(-1, -1).Resize(Ar.Count + 1)), vbLf)
      Ar.Offset(, -1).Clear
    Next
  End With
  Columns("D").Clear
End Sub[/td]
[/tr]
[/table]

HOW TO INSTALL MACROs
------------------------------------
If you are new to macros, they are easy to install and use. To install it, simply press ALT+F11 to go into the VB editor and, once there, click Insert/Module on its menu bar, then copy/paste the above code into the code window that just opened up. That's it.... you are done. To use the macro, go back to the worksheet with your data on it and press ALT+F8, select the macro name (CombinePOs) from the list that appears and click the Run button. The macro will execute and perform the action(s) you asked for. If you will need to do this again in this same workbook, and if you are using XL2007 or above, make sure you save your file as an "Excel Macro-Enabled Workbook (*.xlsm) and answer the "do you want to enable macros" question as "Yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.
 
Upvote 0
Thank you sir. But is there a way we can use formula instead of VBA.
 
Upvote 0
Thank you sir. But is there a way we can use formula instead of VBA.
Only if you have the version of Excel that has the TEXTJOIN function. If you do not have that function available in your version of Excel, you will need to use the macro I created for you. If you do have the right version of Excel, then unfortunately I cannot create a formula for you as I do not have the right version of Excel... you will have to wait for one of the other volunteers who does have it to respond.
 
Upvote 0
Hi,

Like Rick, I also do not have the TEXTJOIN function, if you want a Formula solution, my solution requires 2 Helper Columns (which you can hide):


Book1
ABCDE
1P/NPOWrap Text
2A123 123123 456 189
3A456123,456
4A189AAA123,456,189
5B898989 698
6B698BB89,698
7C852852852 741 963 256 789
8C741852,741
9C963852,741,963
10C256852,741,963,256
11C789CCCCC852,741,963,256,789
Sheet347
Cell Formulas
RangeFormula
C2=IF(COUNTIF(A$2:A2,A2)=COUNTIF(A$2:A$11,A2),REPT(A2,COUNTIF(A$2:A$11,A2)),"")
D2=IF(A2=A1,D1&","&B2,B2)
E2=IF(COUNTIF(A$2:A2,A2)=1,SUBSTITUTE(VLOOKUP(REPT(A2,COUNTIF(A$2:A$11,A2)),C$2:D$11,2,0),",",CHAR(10)),"")


Change/adjust Cell References/Range as needed.
All formulas copied down.
Don't forget to "Wrap Text" for Result Column.
Hide Columns C and D as you wish.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,636
Latest member
laura12345

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