• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to CONCATENATE multiple cell in single cell with separator

ThrottleWorks

Excel Ninja
Hi,

I have a list. I am trying to concatenate this list in a single cell using separator.

For example, I have Cell A1,A2,A3 and A4. Values are a1,a2,a3 and a4.

I want result in cell B1 as a1-a2-a3-a4.

Can anyone please help me this.
 

Attachments

I am trying below code.

Code:
Dim Rng1 As Range
Set Rng1 = Range("n1:n" & EndRowNum)
            For Each Rng In Rng1
                Range("p1") = "=CONCATENATE(N1&"";""&N2)"
            Next Rng

But not sure how to replace N1 with changing reference of row number.
 
I am trying below code.

Code:
Dim Rng1 As Range
Set Rng1 = Range("n1:n" & EndRowNum)
            For Each Rng In Rng1
                Range("p1") = "=CONCATENATE(N1&"";""&N2)"
            Next Rng

But not sure how to replace N1 with changing reference of row number.

This would be

Code:
Dim Rng1 As Range
Set Rng1 = Range("n1:n" & EndRowNum)

For Each Rng In Rng1
    arg = arg & ";" & Rng
Next Rng

Range("p1") = Mid(arg, 2)
 
@Deepak , somehow it's not working at my PC. Will re-check if I have committed any errors.

Thanks for the help.

Just checked & find working

Code:
Sub test()

Dim Rng1 As Range, Rng As Range, EndRowNum As Integer
EndRowNum = 10

Set Rng1 = Range("n1:n" & EndRowNum)

For Each Rng In Rng1
    arg = arg & ";" & Rng
Next Rng

Range("p1") = Mid(arg, 2)
End Sub
 
Back
Top