Concatenate formula

stevewood1

New Member
Joined
Oct 11, 2018
Messages
16
Hello,

I have a list of information in a column that I want to concatenate into a single cell. I need a line break between each line of information but the problem that I have is that as I don't know how much information will be entered into the column each time. I have allowed for possible entries in cells A1 to A50 and so I am ending up with a large amount of blank lines in my concatenated cell result as sometimes there will only be information in cells A1 to A10.

I know that I could use a nested IF formula to check if each cell was not blank but due to the number of cells that could possibly have data in them this would seem to be too large and unworkable.

Is there any other way that I can get a line break only if the original cell was not blank?

Many thanks,

Steve
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Then as far i can think its your first option or a user defined function in VBA. Depends if you can use coding or not.
 
Upvote 0
This UDF will act in a similar way to TEXTJOIN:

Code:
Function TEXTJOIN2(delimiter As String, ignore_empty As Boolean, text_range As Range) As String

Dim c as Range

For Each c In text_range
    If ignore_empty = True Then
        If Len(c) > 0 Then TEXTJOIN2 = TEXTJOIN2 & delimiter & c.Value
    Else
        TEXTJOIN2 = TEXTJOIN2 & delimiter & c.Value
    End If
Next

TEXTJOIN2 = Replace(TEXTJOIN2, delimiter, vbNullString, , 1)

End Function

So add it to a module then in the worksheet you can use what i typed above but i called it TEXTJOIN2.
 
Upvote 0

Forum statistics

Threads
1,224,749
Messages
6,180,727
Members
452,995
Latest member
isldboy

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