Join text in excel

icytuvi

New Member
Joined
Feb 2, 2020
Messages
30
Office Version
  1. 2013
Platform
  1. Windows
Hi,

I have two tables including the 'Database' and 'Summary' as below. In the 'Summary table' I would like to list out all available value in 'Database' and I am using &", " to join text from the cells.

Could you please help me an alternative formula so that there won't be the comma if the cell is blank? In my version of excel, CONCAT is not available.

Thanks a lot.

Book1.xlsx
BCDEFGHIJ
2DatabaseSummary
3Product 1Product 2Product 3Product 4Product 5Product 6Product 1Alabama, Florida, , , ,
4AlabamaHawaiiIowaWashington DC.Product 2Hawaii, Colorado, , , ,
5FloridaColoradoHawaiiProduct 3Iowa, , , , ,
6ColoradoProduct 4, , , , ,
7IowaProduct 5, , , , ,
8MarylandProduct 6Washington DC., Hawaii, Colorado, Iowa, Maryland, Oregon
9Oregon
Sheet1
Cell Formulas
RangeFormula
J3J3=B4&", "&B5&", "&B6&", "&B7&", "&B8&", "&B9
J4J4=C4&", "&C5&", "&C6&", "&C7&", "&C8&", "&C9
J5J5=D4&", "&D5&", "&D6&", "&D7&", "&D8&", "&D9
J6J6=E4&", "&E5&", "&E6&", "&E7&", "&E8&", "&E9
J7J7=F4&", "&F5&", "&F6&", "&F7&", "&F8&", "&F9
J8J8=G4&", "&G5&", "&G6&", "&G7&", "&G8&", "&G9
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
In my version of excel, CONCAT is not available.
It might be time for an upgrade ;) this is trivial in the modern versions of Excel - but for J3 you could try:

Excel Formula:
=MID(IF(B4="",""," ,"&B4)&IF(B5="",""," ,"&B5)&IF(B6="",""," ,"&B6)&IF(B7="",""," ,"&B7)&IF(B8="",""," ,"&B8)&IF(B9="",""," ,"&B9),3,9999)
 
Upvote 0
Solution
Use Power Query. You may have to install Power Query as an Add-in in office 2013.

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    unPiv = Table.UnpivotOtherColumns(Source, {}, "Product", "Value"),
    grp = Table.Group(unPiv, {"Product"}, {{"Combined", each Text.Combine([Value],", ")}})
in
    grp

1716455968026.png
 
Upvote 0
It might be time for an upgrade ;) this is trivial in the modern versions of Excel - but for J3 you could try:

Excel Formula:
=MID(IF(B4="",""," ,"&B4)&IF(B5="",""," ,"&B5)&IF(B6="",""," ,"&B6)&IF(B7="",""," ,"&B7)&IF(B8="",""," ,"&B8)&IF(B9="",""," ,"&B9),3,9999)
Thank you very much, it works perfectly for me! I am using company's laptop and it's kinda difficult to ask them to upgrade
 
Upvote 0
Use Power Query. You may have to install Power Query as an Add-in in office 2013.

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    unPiv = Table.UnpivotOtherColumns(Source, {}, "Product", "Value"),
    grp = Table.Group(unPiv, {"Product"}, {{"Combined", each Text.Combine([Value],", ")}})
in
    grp

View attachment 111803
Thank you very much, I'll try with your suggestion
 
Upvote 0
As yet another alternative, many years ago when TEXTJOIN appeared and our work versions hadn’t caught up I wrote some VBA code to create a user defined function to do the same thing.
You could try this code. It will accept a range, a single cell reference, a literal string value or an array of values.

TEXTJOIN(delimiter, ignore_empty, text1, [text2], [....], etc)
e.g. =TEXTJOIN(" ",FALSE,A1:A3,B1)
=TEXTJOIN(" ",FALSE,"whippets",B2)
=TEXTJOIN(" ",FALSE,{"I","love","whippets"},"a","lot")

All text arguments except text 1 are optional.
ignore_empty is boolean (TRUE/FALSE)



VBA Code:
Function TEXTJOIN(delimiter As String, ignore_empty As Boolean, ParamArray textn() As Variant) As String
    Dim i
    Dim rng
    For Each rng In textn
        If IsObject(rng) Or IsArray(rng) Then
            For Each i In rng
                If Len(i) = 0 Then
                    If Not ignore_empty Then
                        TEXTJOIN = TEXTJOIN & i & delimiter
                    End If
                Else
                    TEXTJOIN = TEXTJOIN & i & delimiter
                End If
            Next
        Else
            If Len(rng) = 0 Then
                If Not ignore_empty Then
                    TEXTJOIN = TEXTJOIN & rng & delimiter
                End If
            Else
                TEXTJOIN = TEXTJOIN & rng & delimiter
            End If
        End If
    Next
    TEXTJOIN = Left(TEXTJOIN, Len(TEXTJOIN) - 1)
End Function
 
Upvote 0
As yet another alternative, many years ago when TEXTJOIN appeared and our work versions hadn’t caught up I wrote some VBA code to create a user defined function to do the same thing.
You could try this code. It will accept a range, a single cell reference, a literal string value or an array of values.

TEXTJOIN(delimiter, ignore_empty, text1, [text2], [....], etc)
e.g. =TEXTJOIN(" ",FALSE,A1:A3,B1)
=TEXTJOIN(" ",FALSE,"whippets",B2)
=TEXTJOIN(" ",FALSE,{"I","love","whippets"},"a","lot")

All text arguments except text 1 are optional.
ignore_empty is boolean (TRUE/FALSE)



VBA Code:
Function TEXTJOIN(delimiter As String, ignore_empty As Boolean, ParamArray textn() As Variant) As String
    Dim i
    Dim rng
    For Each rng In textn
        If IsObject(rng) Or IsArray(rng) Then
            For Each i In rng
                If Len(i) = 0 Then
                    If Not ignore_empty Then
                        TEXTJOIN = TEXTJOIN & i & delimiter
                    End If
                Else
                    TEXTJOIN = TEXTJOIN & i & delimiter
                End If
            Next
        Else
            If Len(rng) = 0 Then
                If Not ignore_empty Then
                    TEXTJOIN = TEXTJOIN & rng & delimiter
                End If
            Else
                TEXTJOIN = TEXTJOIN & rng & delimiter
            End If
        End If
    Next
    TEXTJOIN = Left(TEXTJOIN, Len(TEXTJOIN) - 1)
End Function
Thank you very much
 
Upvote 0
OP, I have been waiting to post this because I wanted you to get your answer first without distraction. I have to say that I love your forum avatar. Is he/she yours? He's very cute!

I have been a lifelong dog lover. A few years ago, I had a new neighbor move in next door to me. I got to know him and his family. They had an orange cat with a cute little personality. I never liked cats to begin with but he completely won me over. I'm officially a dog AND a cat person now. So much so, that I plan on adopting a cat someday. I miss Duke (cat) a lot!

Could you please help me an alternative formula so that there won't be the comma if the cell is blank? In my version of excel, CONCAT is not available.

By the way, I am using a version of MS Office older than yours and the =CONCATENATE function is definitely available. I suspect you have it as well. You probably just missed it.
 
Upvote 0

Forum statistics

Threads
1,216,500
Messages
6,131,015
Members
449,615
Latest member
Nic0la

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