|
发表于 2023-2-26 10:58
来自手机
|
显示全部楼层
Sub JudgeColor()
Dim rng As Range
Dim i As Long
Dim j As Long
Dim strColor As String
Dim blnRed As Boolean
Dim blnBlack As Boolean
Set rng = Range("B1:B" & Range("B" & Rows.Count).End(xlUp).Row)
For i = 1 To rng.Rows.Count
blnRed = False
blnBlack = False
For j = 1 To Len(rng.Cells(i, 1).Value)
strColor = rng.Cells(i, 1).Characters(j, 1).Font.Color
If strColor = vbRed Then
blnRed = True
ElseIf strColor = vbBlack Then
blnBlack = True
End If
Next j
If blnRed And blnBlack Then
rng.Cells(i, 3).Value = "混合色"
ElseIf blnRed Then
rng.Cells(i, 3).Value = "红色"
ElseIf blnBlack Then
rng.Cells(i, 3).Value = "黑色"
End If
Next i
End Sub |
|