Skip to content

Instantly share code, notes, and snippets.

@doggy8088
Created September 16, 2018 07:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doggy8088/96aee1271688ac5f6894a3f70b0b68b3 to your computer and use it in GitHub Desktop.
Save doggy8088/96aee1271688ac5f6894a3f70b0b68b3 to your computer and use it in GitHub Desktop.
Function GetItemSize(value As String, Optional separator As String = ",")
Dim DedupeArray As Variant
DedupeArray = RemoveDupes(Split(value, separator))
GetItemSize = UBound(DedupeArray) - LBound(DedupeArray)
End Function
Function RemoveDupStrings(value As String, Optional separator As String = ",")
RemoveDupStrings = Join(RemoveDupes(Split(value, separator)), separator)
End Function
Function RemoveDupes(InputArray) As Variant
Dim OutputArray As Variant
Dim CurrentValue As Variant
Dim A As Variant
On Error Resume Next
OutputArray = Array("")
For Each CurrentValue In InputArray
CurrentValue = Trim(CurrentValue)
Flag = 0
If IsEmpty(CurrentValue) Then GoTo skip
For Each A In OutputArray
If A = CurrentValue Then
Flag = 1
Exit For
End If
Next A
If Flag = 0 Then
ReDim Preserve OutputArray(UBound(OutputArray, 1) + 1)
OutputArray(UBound(OutputArray, 1) - 1) = CurrentValue
End If
skip:
Next
RemoveDupes = OutputArray
End Function
Public Function GetString(ByVal cell As Range) As String
GetString = cell.value & ""
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment