Join all row cells in a single cell by vertical bar

motilulla

Well-known Member
Joined
Feb 13, 2008
Messages
2,422
Office Version
  1. 2010
Hello,</SPAN></SPAN>

I need to Join P:Y column each row cells in single cell by using a vertical bar, result require in AA column as shown below </SPAN></SPAN>

Example</SPAN></SPAN>


Book1
PQRSTUVWXYZAA
1
2
3n1n2n3n4n5n6n7n8n9n10Join
4111311 | 13
591012139 | 10 | 12
6910129 | 10 | 12
7101310 | 13
8911129 | 11 | 12
9911139 | 11 | 13
10349103 | 4 | 9 | 10
111234591 | 2 | 3 | 4 | 5 | 9
Sheet1


Thank you all </SPAN></SPAN>

Excel 2000</SPAN></SPAN>
Regards,</SPAN></SPAN>
Moti</SPAN></SPAN>
 
Last edited:
@ alansidman, Adjust code ranges accordingly my data, code does not work when there are data in next to AA columns thank you for your help.</SPAN></SPAN>

@ Rick, thank you your formula results fine.
</SPAN></SPAN>

@ YasserKhalil, thank you your code results as treat.
</SPAN></SPAN>

@ mohadin, tried your last post#10 code, but it does not work when there are data in next to AA columns thank you for your help.
</SPAN></SPAN>

Everyone have a good day
</SPAN></SPAN>

Kind Regards,
</SPAN></SPAN>
Moti
</SPAN></SPAN>
 
Upvote 0

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Hello,</SPAN></SPAN>

I am sorry to replant my query again need all results with 2 digits as shown in the example below...Please help
</SPAN></SPAN>


Book1
PQRSTUVWXYZAA
1
2
3n1n2n3n4n5n6n7n8n9n10Join
4111311|13
5910121309|10|12|13
69101209|10|12
7101310|13
89111209|11|12
99111309|11|13
103491003|04|09|10
1112345901|02|030|04|05|09
Sheet1


Thank you all
</SPAN></SPAN>

Excel 2000
</SPAN></SPAN>
Regards,
</SPAN></SPAN>
Moti
</SPAN></SPAN>
 
Last edited:
Upvote 0
I am sorry to replant my query again need all results with 2 digits as shown in the example below...Please help[/COLOR]</SPAN></SPAN>

Here is a formula solution...

Code:
[table="width: 500"]
[tr]
	[td]=SUBSTITUTE(TRIM(IF(A2="","",TEXT(A2,"00 "))&IF(B2="","",TEXT(B2,"00 "))&IF(C2="","",TEXT(C2,"00 "))&IF(D2="","",TEXT(D2,"00 "))&IF(E2="","",TEXT(E2,"00 "))&IF(F2="","",TEXT(F2,"00 "))&IF(G2="","",TEXT(G2,"00 "))&IF(H2="","",TEXT(H2,"00 "))&IF(I2="","",TEXT(I2,"00 "))&IF(J2="","",TEXT(J2,"00 ")))," ","|")[/td]
[/tr]
[/table]
 
Upvote 0
Here is a formula solution...

Code:
[TABLE="width: 500"]
<TBODY>[TR]
[TD]=SUBSTITUTE(TRIM(IF(A2="","",TEXT(A2,"00 "))&IF(B2="","",TEXT(B2,"00 "))&IF(C2="","",TEXT(C2,"00 "))&IF(D2="","",TEXT(D2,"00 "))&IF(E2="","",TEXT(E2,"00 "))&IF(F2="","",TEXT(F2,"00 "))&IF(G2="","",TEXT(G2,"00 "))&IF(H2="","",TEXT(H2,"00 "))&IF(I2="","",TEXT(I2,"00 "))&IF(J2="","",TEXT(J2,"00 ")))," ","|")
[/TD]
[/TR]
</TBODY>[/TABLE]
Rick, it is absolutely perfect! I appreciate your help</SPAN></SPAN>

Have a nice day
</SPAN></SPAN>

Kind Regards,
</SPAN></SPAN>
Moti :)
</SPAN></SPAN>

Note: I am observing in the example got result error in the AA11, which formula did correct
 
Last edited:
Upvote 0
Hi again
what about
Code:
Sub test2()
    Dim b, c As Variant, x
    Dim lr, lc, i
    Range("aa4:aa11").ClearContents
    Range("aa4:aa11").Formula = "=COUNTA(p4:y4)"
    c = Application.Transpose(Range("aa4:aa11").Value)
    For i = 4 To Cells(Rows.Count, 16).End(xlUp).Row
        b = Application.Transpose(WorksheetFunction.Transpose(Cells(i, 16).Resize(, c(i - 3))))
        b = "0" & Join(b, "|0")
        Cells(i, 27) = b
    Next
End Sub
 
Upvote 0
Hi again
what about
Code:
Sub test2()
    Dim b, c As Variant, x
    Dim lr, lc, i
    Range("aa4:aa11").ClearContents
    Range("aa4:aa11").Formula = "=COUNTA(p4:y4)"
    c = Application.Transpose(Range("aa4:aa11").Value)
    For i = 4 To Cells(Rows.Count, 16).End(xlUp).Row
        b = Application.Transpose(WorksheetFunction.Transpose(Cells(i, 16).Resize(, c(i - 3))))
        b = "0" & Join(b, "|0")
        Cells(i, 27) = b
    Next
End Sub
Hello mohadin, Please can you test your code I think you have to check it is adding extra "0" in the each value it has to add only where is one digit number to make them 2 digit it is converting 2 digit in to 3 digit </SPAN></SPAN>

Kind Regards,
</SPAN></SPAN>
Moti
</SPAN></SPAN>
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,185
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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