Tested in Excel 2016 (16.0.9330.2073) 64-bit
A function to test which character can be used to join data safely to be able to split it later.
- Public Function FindDelimiter(RangeToTest As Range) As String
- Const DelimiterList = "; , | ! @ # $ % ^ & < > : \ } { +"
- Dim DelimArr, myDelim, Found As Boolean
- Dim i, j
- DelimArr = Split(DelimiterList, " ")
- For i = 0 To UBound(DelimArr)
- Found = True 'assume the delimiter is ok
- For j = 1 To RangeToTest.Count
- If InStr(1, RangeToTest(j).Value, DelimArr(i)) > 0 _
- Then Found = False ' if it exists in the analized range, it's not found
- Next j
- If Found Then ' use this one and stop
- myDelim = DelimArr(i)
- Exit For
- End If
- Next i
- FindDelimiter = myDelim
- End Function