Posted By

lolrenx on 12/20/12


Tagged

String excel vba range concatenate


Versions (?)

Range to String


 / Published in: Visual Basic
 

Concatenate all text in cells with defined separator

  1. Option Explicit
  2. Option Compare Text
  3.  
  4. 'UDF
  5. Public Function Range_to_String(tgtRange As Range, Separator As String) As String
  6.  
  7. If tgtRange Is Nothing Then Exit Function
  8.  
  9. Dim tCell As Range
  10. For Each tCell In tgtRange.Cells
  11. Range_to_String = Range_to_String & Separator & tCell
  12. Next tCell
  13.  
  14. Range_to_String = Right(Range_to_String, Len(Range_to_String) - 1)
  15.  
  16. End Function

Report this snippet  

You need to login to post a comment.