New to the forum. I'm stuck on this replacement loop.
Function CCL2(ByRef txt As String, ByRef x As String)
' txt as starting text
' x as cell containing array that can be split by " " (space character)
' y as a String Array
Dim y() As String
' split x into array by " "
y = Split(StrConv(x, vbUnicode), " ")
' if an error is observed, moved to Next
On Error Resume Next
' For each y string found in txt
For Each y In txt
' replace the unwanted y with "" leaving the remaining txt
CCL2 = Replace(txt, y, "")
' perform for every y variant
Next y
'Cell A1 = x = "AK AL"
'Cell B1 = txt = "AK, AL, AR, AZ"
'Cell C1 = CCL2(B1,A1) = #REF!
End Function
Function CCL2(ByRef txt As String, ByRef x As String)
' txt as starting text
' x as cell containing array that can be split by " " (space character)
' y as a String Array
Dim y() As String
' split x into array by " "
y = Split(StrConv(x, vbUnicode), " ")
' if an error is observed, moved to Next
On Error Resume Next
' For each y string found in txt
For Each y In txt
' replace the unwanted y with "" leaving the remaining txt
CCL2 = Replace(txt, y, "")
' perform for every y variant
Next y
'Cell A1 = x = "AK AL"
'Cell B1 = txt = "AK, AL, AR, AZ"
'Cell C1 = CCL2(B1,A1) = #REF!
End Function