所以我的目標是更改任何包含單詞「總計:」的字符串的顏色。然後使用邏輯來突出顯示單元格B1和C1。我目前的代碼可以改變顏色,但是當我使用邏輯它認爲單元格沒有填充。從條件格式確定單元格顏色的更改
Sub Macro6()
'
' Macro6 Macro
'
'ActiveWindow.SmallScroll Down:=-12
Range("A1:A381").Select
Selection.FormatConditions.Add Type:=xlTextString, String:="Totals:",
TextOperator:=xlContains
'
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
' With Selection.FormatConditions(1).Font
' .Color = -16383844
' .TintAndShade = 0
' End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13551615 '16777215 '
.TintAndShade = 0
End With
'Selection.FormatConditions(1).StopIfTrue = False
'lastrow = Sheet4.Cells(Sheet4.Rows.Count, "A").End(xlUp).Row
If Sheet1.Cells(9, 1).Interior.Color = 13551615 Then '16777215
MsgBox ("yes")
Else
MsgBox ("wrong")
MsgBox (Sheet4.Cells(6, 1).Interior.Color)
End If
End Sub
使用格式..... – KyloRen