Last active
April 20, 2017 12:40
-
-
Save ndthanh/f8714cf0b9c62171854700e46f04ec3f to your computer and use it in GitHub Desktop.
Nối chuỗi có dấu ngăn cách
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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