我想要我的 Formula1:="=$J10=""S""" 一个相对地址而不是绝对地址。一定是A10,怎么写?
Sub Makro7()
ActiveCell.Range("A1:A31,B1:B31").Select
ActiveCell.Offset(0, 1).Range("A1").Activate
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$J10=""S"""
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = RGB(255, 0, 0)
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
End Sub
答案 0 :(得分:0)
目前还不清楚 CF 的意图是什么,但这样的事情会起作用:
Sub Makro7()
Dim rng As Range
Set rng = ActiveCell.Resize(31, 2)
rng.Cells(1, 2).Activate
With rng.FormatConditions.Add(Type:=xlExpression, _
Formula1:="=" & rng.Cells(1).Address(False, False) & "=""S""")
.SetFirstPriority
.StopIfTrue = False
With .Interior
.PatternColorIndex = xlAutomatic
.Color = RGB(255, 0, 0)
.TintAndShade = 0
End With
End With
End Sub