Created
October 11, 2011 03:51
-
-
Save jesantos/1277225 to your computer and use it in GitHub Desktop.
Excel VBA; Merge Values using a delimiter
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
Function MERGEVALUES(rn As Range, del As String) | |
Dim cell As Range | |
Dim result As String | |
Dim index As Integer | |
Dim textSplit As Variant | |
Dim curVal As String | |
For Each cell In rn | |
textSplit = Split(cell.text, del) | |
For index = LBound(textSplit) To UBound(textSplit) | |
curVal = textSplit(index) | |
If result = "" Then | |
result = curVal | |
Else | |
If InStr(result, curVal & del) < 1 Then | |
result = result & del & curVal | |
End If | |
End If | |
Next | |
Next | |
MERGEVALUES = result | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment