Sub FilmTypeWidthLength()
Dim R As Long, X As Long, MM As Long, SP As Long
Dim Txt As Variant, Data As Variant, Results As Variant
Data = Range("B2", Cells(Rows.Count, "B").End(xlUp))
Columns("B").Interior.ColorIndex = xlColorIndexNone
ReDim Results(1 To UBound(Data), 1 To 3)
For R = 1 To UBound(Data)
MM = InStr(1, Replace(Data(R, 1), "x", " ", , , vbTextCompare), "mm ", vbTextCompare)
If MM = 0 Then
Cells(R + 1, "B").Interior.ColorIndex = 3
Else
SP = InStrRev(Data(R, 1), " ", MM)
Txt = Split(Application.Trim(Mid(Replace(Data(R, 1), "x", " ", , , vbTextCompare), SP + 1)))
If Len(Txt(0)) < 3 Or Len(Txt(0)) < 2 Then
Cells(R + 1, "B").Interior.ColorIndex = 3
ElseIf (Not Right(Txt(0), 3) Like "#[Mm][Mm]") Or (Not Right(Txt(1), 2) Like "#[Mm]") Then
Cells(R + 1, "B").Interior.ColorIndex = 3
Else
Results(R, 1) = Left(Data(R, 1), SP - 1)
Results(R, 2) = Mid(Data(R, 1), SP + 1, MM - SP - 1)
Results(R, 3) = Val(Mid(Replace(Data(R, 1), "x", " ", , , vbTextCompare), MM + 3))
End If
End If
Next
Range("C2:E" & UBound(Results)) = Results
End Sub |