Combining Cell Contents (Part 2)

  • Thread starter Thread starter PaolaAndrea
  • Start date Start date
P

PaolaAndrea

Hello,

Thank you for your previous reply, it was great.

One more variable than I didn't think about, if cell B2 is empty how can I
make sure that only A2 is populated and that I don't have a blank line on the
bottom?

Example:

A2 = 109 Vine Hill & B2 = (Empty)

Result:
109 Vine Hill

NOT:
109 Vine Hill
(Empty Line)

Thank you.

Sincerely,

PaolaAndrea
 
First, it's good to respond in the same thread.

Second, since you had multiple responses, you'll want to share the formula you
used--and what happened when you tried it.
 
Use this UDF

Function ConCatRange(CellBlock As Range) As String
Dim Cell As Range
Dim sbuf As String
For Each Cell In CellBlock
If Len(Cell.text) > 0 Then sbuf = sbuf & Cell.text & Chr(10)
Next
ConCatRange = Left(sbuf, Len(sbuf) - 1)
End Function

If any cell is blank, no extra linefeed is entered.

=ConCatRange(A2:F2) or whatever range you choose.


Gord Dibben MS Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top