Concatenate Cells

dandy

New Member
Joined
Apr 3, 2017
Messages
22
I have code that pulls from a database and inputs into an excel sheet (shown below).


Code:
 Selectstring = "SELECT " & c.Item("Ticket1") & _
                   ", " & c.Item("Description")

    fromString = "FROM " & ibmLib1 & "." & t.Item("NCType") & " " & t.Item("NCType") & _
                 ", " & ibmLib1 & "." & t.Item("NCRs") & " " & t.Item("NCRs")

    whereString = "WHERE " & c.Item("Ticket3") & "=" & c.Item("Ticket1")

    strSql = Selectstring & " " & fromString & " " & whereString
    
        '################PERFORM THE QUERY################
    Set conn = Open400Conn()
    Set rs = Query(conn, strSql)
    descTab.Range("A1").Value = "Ticket"
    descTab.Range("B1").Value = "Description"
    descTab.Range("A2").CopyFromRecordset (rs)
    conn.Close


The way the database is setup, it only can record a certain amount of characters per line and so I get multiple lines for one record (example below)


A
B
Ticket
Description
1
test
2
CN 11: 1-22 check 1.3504 or
2
.0084 o/max; CN 10: S/N 14
2
check 0.0303 or .003 o/max

<tbody>
</tbody>











I would like the query to say something like "If there is a duplicate value in column A, combine all the text in the corresponding cells into one line."

So instead of having it like it is shown directly above, it would come out like this:

A
B
Ticket
Description
1
test
1
CN 11: 1-22 check 1.3504 or .0084 o/max; CN 10: S/N 14 check 0.0303 or .003 o/max

<tbody>
</tbody>
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,216,038
Messages
6,128,450
Members
449,453
Latest member
jayeshw

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