More help with a UDF

E

Excel Helps

Could I modify the UDF seen below to do this?
a¦a|b¦b|c¦c|d¦d

where abcd are data in cells in one sheet
and the piped data is placed into another sheet with duplications of the
origial sheet, separated by broken pipes
and solid pipes.


Function ConCatRange(CellBlock As Range) As String
Dim Cell As Range
Dim sbuf As String
Dim pipe As Boolean
pipe = True
For Each Cell In CellBlock
pipe = Not pipe

If Len(Cell.Text) > 0 Then
If pipe = False Then
sbuf = sbuf & Cell.Text & Chr(166)
Else
sbuf = sbuf & Cell.Text & "|"
End If
End If
Next
ConCatRange = sbuf
End Function
 

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

Top