Combine Text From Cells

nhbcai

New Member
Joined
Jun 28, 2011
Messages
18
I have column of product codes that I need to insert into a field in my shopping cart. There are about 600 of them and the text in each field needs to be separated by commas.

I thought Concatenate may be a good idea, but that's a heck of a lot of clicking. haha

Does anyone know how I can join the text in all the cells into one field that is comma delimited.

To illustrate:

Column A
EC-001
EC-002
EC-003
EC-004
EC-005

What I need is data joined too look like this:
EC-001,EC-002,EC-003,EC004,EC-005

But there are like 650 of them. Literally.

Any ideas?

I've gotten a lot of help from this forum for free. And I don't take that lightly.

Thanks.
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
How are you going to insert the field into the shopping cart exactly? Will it take such a large string ( well in excess of 4000 characters )?

In the meantime, here's a UDF to do the concatenation:
Code:
Function mconcatmine(myrange As Range) As String
    mconcatmine = ""
    For Each c In myrange
        If Not IsEmpty(c) Then
            mconcatmine = mconcatmine & c.Value & ","
        End If
    Next
    If Len(mconcatmine) > 0 Then mconcatmine = Left(mconcatmine, Len(mconcatmine) - 1)
    
End Function
 
Upvote 0
Try this:-
Code:
[COLOR="Navy"]Sub[/COLOR] MG30Jun51
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Set[/COLOR] Rng = Range(Range("A1"), Range("A" & rows.count).End(xlUp))
Range("B1") = Join(Evaluate("transpose(" & Rng.Address & ")"), ", ")
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0
Code:
[COLOR="Blue"]Sub[/COLOR] HW()
    [COLOR="Blue"]Dim[/COLOR] arr [COLOR="Blue"]As[/COLOR] [COLOR="Blue"]Variant[/COLOR], i [COLOR="Blue"]As[/COLOR] [COLOR="Blue"]Long[/COLOR]
    arr = Range("A1:A" & Range("A1").End(xlDown).Row)
    [COLOR="Blue"]For[/COLOR] i = 1 [COLOR="Blue"]To[/COLOR] [COLOR="Blue"]UBound[/COLOR](arr, 1)
        Activcell = ActiveCell & arr(i) & IIf(i = [COLOR="Blue"]UBound[/COLOR](arr, 1), "", ",")
    [COLOR="Blue"]Next[/COLOR]
[COLOR="Blue"]End[/COLOR] [COLOR="Blue"]Sub[/COLOR]
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,761
Members
452,940
Latest member
rootytrip

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