Hi,
I've got the following product dimensions in a single cell:
[TABLE="width: 889"]
<tbody>[TR]
[TD="width: 889"]Small: 9'' H x Small: 3'' Dia x Medium: 9.5'' H x Medium: 4.25'' Dia x Large: 12'' H x Large: 4.25'' Dia
My goal is to only have the word Small listed once, Medium Once, Large Once...so it would look like
[/TD]
[/TR]
</tbody>[/TABLE]
Small: 9'' H x 3'' Dia x Medium: 9.5'' H x 4.25'' Dia x Large: 12'' H x 4.25'' Dia
I've tried using the following VBA:
Function RemoveDupes2(txt As String, Optional delim As String = " ") As String
Dim x
'Updateby20140924
With CreateObject("Scripting.Dictionary")
.CompareMode = vbTextCompare
For Each x In Split(txt, delim)
If Trim(x) <> "" And Not .exists(Trim(x)) Then .Add Trim(x), Nothing
Next
If .Count > 0 Then RemoveDupes2 = Join(.keys, delim)
End With
End Function
Problem is that it removes the "Dia" and other words since they are duplicate word as well.
Can anyone help me specify which duplicate words I want to remove using a formula or VBA?
Thank you!
I've got the following product dimensions in a single cell:
[TABLE="width: 889"]
<tbody>[TR]
[TD="width: 889"]Small: 9'' H x Small: 3'' Dia x Medium: 9.5'' H x Medium: 4.25'' Dia x Large: 12'' H x Large: 4.25'' Dia
My goal is to only have the word Small listed once, Medium Once, Large Once...so it would look like
[/TD]
[/TR]
</tbody>[/TABLE]
Small: 9'' H x 3'' Dia x Medium: 9.5'' H x 4.25'' Dia x Large: 12'' H x 4.25'' Dia
I've tried using the following VBA:
Function RemoveDupes2(txt As String, Optional delim As String = " ") As String
Dim x
'Updateby20140924
With CreateObject("Scripting.Dictionary")
.CompareMode = vbTextCompare
For Each x In Split(txt, delim)
If Trim(x) <> "" And Not .exists(Trim(x)) Then .Add Trim(x), Nothing
Next
If .Count > 0 Then RemoveDupes2 = Join(.keys, delim)
End With
End Function
Problem is that it removes the "Dia" and other words since they are duplicate word as well.
Can anyone help me specify which duplicate words I want to remove using a formula or VBA?
Thank you!
Last edited: