Skip to content

Instantly share code, notes, and snippets.

@ndthanh
Last active April 20, 2017 12:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ndthanh/f8714cf0b9c62171854700e46f04ec3f to your computer and use it in GitHub Desktop.
Save ndthanh/f8714cf0b9c62171854700e46f04ec3f to your computer and use it in GitHub Desktop.
Nối chuỗi có dấu ngăn cách
'https://www.hocexcel.online
Function hTextJoin(d As String, e As Boolean, r As Range) As String
If r.Count = 1 Then hTextJoin = r.Value
Dim a, b As Long, c As String
If r.Rows.Count = 1 Then
a = Application.Transpose(Application.Transpose(r))
ElseIf r.Columns.Count = 1 Then
a = Application.Transpose(r)
Else
hTextJoin = "!!!not support"
Exit Function
End If
If e Then
For b = LBound(a) To UBound(a)
If Len(Trim(a(b))) > 0 Then
c = c & a(b) & d
End If
Next
Else
For b = LBound(a) To UBound(a)
c = c & a(b) & d
Next
End If
hTextJoin = Left(c, Len(c) - Len(d))
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment