Вы можете использовать Dictionary
для отслеживания всего, что поступает из диапазона, а затем просто сбросить ключи словаря обратно в виде строки:
Public Function GetDistinct(inRange As Range)
Dim dict As Object
Set dict = CreateObject("Scripting.Dictionary")
'collect everything into the dictionary
Dim rngCell As Range
For Each rngCell In inRange.Cells
If rngCell.Value <> "" And Not dict.Exists(rngCell.Value) Then
dict.Add rngCell.Value, 1
End If
Next rngCell
'The keys of a dictionary are an array
'So we can just Join() them with a ", "
GetDistinct = Join(dict.Keys, ", ")
End Function
На практике:
![enter image description here](https://i.stack.imgur.com/oP3pa.png)