|
▼Characters さん:
こんにちは
文字列の区切りは全角スペース1文字という前提です。
Sub Test()
Dim v As Variant
Dim i As Long
Dim myStr As String
Dim myIndex As Long
Dim f As Long
Dim z As Long
Dim l As Long
With Range("K2")
.Font.ColorIndex = xlAutomatic
v = Split(.Value, vbLf)
For i = LBound(v) To UBound(v)
myIndex = 0
If Left(v(i), 2) = "入荷" Then
myIndex = 5
ElseIf Left(v(i), 3) = "未入荷" Then
myIndex = 3
End If
If myIndex > 0 Then
f = InStr(v(i), " ") + 1
l = InStr(f, v(i), " ") - f + 1
.Characters(Start:=z + f, Length:=l).Font.ColorIndex = myIndex
End If
z = z + Len(v(i)) + 1
Next
End With
End Sub
|
|