Range to String


/ Published in: Visual Basic

Concatenate all text in cells with defined separator


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.