View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
isabelle isabelle is offline
external usenet poster
 
Posts: 587
Default Concatenate a row that is selected and include blank cells

hi Howard,

Function ConcatMe(Rng As Range) As String
Dim cl As Range
ConcatMe = ""
For Each cl In Rng
If cl = "" Then
ConcatMe = ConcatMe & " "
Else
ConcatMe = ConcatMe & cl.Text
End If
Next cl
End Function

isabelle

Le 2013-06-15 20:53, Howard a écrit :
Can this neat little snippet be altered to work on a row of selected cells AND include the blanks?

Works fine as is with =ConcatMe("A1:Z1") but omits any blanks.

I may want only A1:G1 including the blank cells if any. =ConcatMe('Selection')

Thanks,
Howard

Option Explicit

Function ConcatMe(Rng As Range) As String

Dim cl As Range

ConcatMe = ""

For Each cl In Rng
ConcatMe = ConcatMe & cl.Text
Next cl

End Function