Sub kTest()
Dim a, i As Long, x, y, c As Long, iteAry, applAry, wirAry, conAry, insAry, firAry, comAry, hvaAry, iceAry, ligAry, _
medAry, gasAry, ppeAry, pfdAry, powAry, sigAry, watAry, hazAry
iteAry = Array("UL 60950", "UL 60950-1", "UL 1459", "UL 497", "UL 497A", "UL 497B", "UL 497C", _
"UL 1863", "UL 1310", "UL 1012", "UL 61965", "UL 60601-1", "UL 60601A-1", "UL 60601B-1", _
"UL 60601C-1", "UL 1863")
a = Range("n8", Range("m" & Rows.Count).End(xlUp))
ReDim w(1 To UBound(a, 1), 1 To 1)
For i = 1 To UBound(a, 1)
x = Split(a(i, 1), ",")
For c = 0 To UBound(x)
y = Application.Match(Trim(x(c)), iteAry, 0)
If Not IsError(y) Then w(i, 1) = "ITE": Exit For
Next
For c = 0 To UBound(x)
y = Application.Match(Trim(x(c)), applAry, 0)
If Not IsError(y) Then
If Not IsEmpty(w(i, 1)) Then
w(i, 1) = w(i, 1) & ", " & "Appliances"
Else
w(i, 1) = "Appliances": Exit For
End If
End If
Next
For c = 0 To UBound(x)
y = Application.Match(Trim(x(c)), wirAry, 0)
If Not IsError(y) Then
If Not IsEmpty(w(i, 1)) Then
w(i, 1) = w(i, 1) & ", " & "Wire & Cable"
Else
w(i, 1) = "Wire & Cable": Exit For
End If
End If
Next
For c = 0 To UBound(x)
y = Application.Match(Trim(x(c)), conAry, 0)
If Not IsError(y) Then
If Not IsEmpty(w(i, 1)) Then
w(i, 1) = w(i, 1) & ", " & "Consumer Electronics"
Else
w(i, 1) = "Consumer Electronics": Exit For
End If
End If
Next
For c = 0 To UBound(x)
y = Application.Match(Trim(x(c)), insAry, 0)
If Not IsError(y) Then
If Not IsEmpty(w(i, 1)) Then
w(i, 1) = w(i, 1) & ", " & "Insulating Materials"
Else
w(i, 1) = "Insulating Materials": Exit For
End If
End If
Next
For c = 0 To UBound(x)
y = Application.Match(Trim(x(c)), firAry, 0)
If Not IsError(y) Then
If Not IsEmpty(w(i, 1)) Then
w(i, 1) = w(i, 1) & ", " & "Fire"
Else
w(i, 1) = "Fire": Exit For
End If
End If
Next
For c = 0 To UBound(x)
y = Application.Match(Trim(x(c)), comAry, 0)
If Not IsError(y) Then
If Not IsEmpty(w(i, 1)) Then
w(i, 1) = w(i, 1) & ", " & "Components"
Else
w(i, 1) = "Components": Exit For
End If
End If
Next
For c = 0 To UBound(x)
y = Application.Match(Trim(x(c)), hvaAry, 0)
If Not IsError(y) Then
If Not IsEmpty(w(i, 1)) Then
w(i, 1) = w(i, 1) & ", " & "HVAC"
Else
w(i, 1) = "HVAC": Exit For
End If
End If
Next
For c = 0 To UBound(x)
y = Application.Match(Trim(x(c)), iceAry, 0)
If Not IsError(y) Then
If Not IsEmpty(w(i, 1)) Then
w(i, 1) = w(i, 1) & ", " & "ICE"
Else
w(i, 1) = "ICE": Exit For
End If
End If
Next
For c = 0 To UBound(x)
y = Application.Match(Trim(x(c)), ligAry, 0)
If Not IsError(y) Then
If Not IsEmpty(w(i, 1)) Then
w(i, 1) = w(i, 1) & ", " & "Lighting"
Else
w(i, 1) = "Lighting": Exit For
End If
End If
Next
For c = 0 To UBound(x)
y = Application.Match(Trim(x(c)), medAry, 0)
If Not IsError(y) Then
If Not IsEmpty(w(i, 1)) Then
w(i, 1) = w(i, 1) & ", " & "Medical & Dental"
Else
w(i, 1) = "Medical & Dental": Exit For
End If
End If
Next
For c = 0 To UBound(x)
y = Application.Match(Trim(x(c)), gasAry, 0)
If Not IsError(y) Then
If Not IsEmpty(w(i, 1)) Then
w(i, 1) = w(i, 1) & ", " & "Gas & Oil"
Else
w(i, 1) = "Gas & Oil": Exit For
End If
End If
Next
For c = 0 To UBound(x)
y = Application.Match(Trim(x(c)), ppeAry, 0)
If Not IsError(y) Then
If Not IsEmpty(w(i, 1)) Then
w(i, 1) = w(i, 1) & ", " & "PPE"
Else
w(i, 1) = "PPE": Exit For
End If
End If
Next
For c = 0 To UBound(x)
y = Application.Match(Trim(x(c)), pfdAry, 0)
If Not IsError(y) Then
If Not IsEmpty(w(i, 1)) Then
w(i, 1) = w(i, 1) & ", " & "PFD"
Else
w(i, 1) = "PFD": Exit For
End If
End If
Next
For c = 0 To UBound(x)
y = Application.Match(Trim(x(c)), powAry, 0)
If Not IsError(y) Then
If Not IsEmpty(w(i, 1)) Then
w(i, 1) = w(i, 1) & ", " & "Power Distribution"
Else
w(i, 1) = "Power Distribution": Exit For
End If
End If
Next
For c = 0 To UBound(x)
y = Application.Match(Trim(x(c)), sigAry, 0)
If Not IsError(y) Then
If Not IsEmpty(w(i, 1)) Then
w(i, 1) = w(i, 1) & ", " & "Security & Signal"
Else
w(i, 1) = "Security & Signal": Exit For
End If
End If
Next
For c = 0 To UBound(x)
y = Application.Match(Trim(x(c)), watAry, 0)
If Not IsError(y) Then
If Not IsEmpty(w(i, 1)) Then
w(i, 1) = w(i, 1) & ", " & "Water"
Else
w(i, 1) = "Water": Exit For
End If
End If
Next
For c = 0 To UBound(x)
y = Application.Match(Trim(x(c)), hazAry, 0)
If Not IsError(y) Then
If Not IsEmpty(w(i, 1)) Then
w(i, 1) = w(i, 1) & ", " & "Hazardous Location"
Else
w(i, 1) = "Hazardous Location": Exit For
End If
End If
Next
Next
With Range("n8")
.Resize(i - 1).Value = w
End With
End Sub
Bookmarks