Pages

Monday, January 30, 2012

UDF to concatenate non blank cells in a range

If you want to concatenate non blank cells in a range . Snapshot below-





Function concatenate_nonblanks(x As Range, spl As String)
Dim cell As Range
Dim rsl As String
For Each cell In x
If cell <> vbNullString Then
rsl = rsl & spl & cell
End If
Next
concatenate_nonblanks = Right(rsl, Len(rsl) - 1)
End Function

No comments:

Post a Comment