String concatenation can be a bit of a frustrating process, but it's doable. You can keep adding "needs" to this to make it unmanageable, but the ability to point to a range of cells and say "concatenate all these text strings into a single cell"...that's not that hard to ADD INTO your spreadsheet.
I have several User Defined Functions (UDFs) that can be added to your sheet to give you the new function. The simplest I use is called ConCatRange() and it doesn't take any parameters other than the range of cells you want to join.
Function ConCatRange(CellBlock As Range) As String
Dim Cell As Range, sbuf As String
For Each Cell In CellBlock
If Len(Cell.Text) > 0 Then sbuf = sbuf & Cell.Text & " " 'Make this ", " to string together with comma delimiters
Next Cell
ConCatRange = Left(sbuf, Len(sbuf) - 2)
End Function
How to install the UDF:
1. Open up your workbook
2. Get into VB Editor (Press Alt+F11)
3. Insert a new module (Insert > Module)
4. Copy and Paste in your code (given above)
5. Get out of VBA (Press Alt+Q)
6. Save your sheet
The UDF is installed and ready to use.
It's used in your sheet, for example, like this:
=ConCatRange(G1:G6)
Bookmarks