Why, different conditional format’s formula were generated by same marco? Reason: The address of cell in conditional format’s formula refer ONLY to the activate cell(s) or Selection. If we select the different cell before marco run, the formula shows different cell’s address after marco run. Solving method: add the code “Range(Add).select” in LZ’macro: conf = "=and($A$" & r & "<=" & ca & ",$B$" & r & ">=" & ca & ",$C$" & r Range(Add).Select Range(Add).FormatConditions.Add Type:=xlExpression, Formula1:=conf & "=""Normal"")"
Under same case, add “arr.select” in my macro: Cells.FormatConditions.Delete arr.Select arr.FormatConditions.Add Type:=xlExpression, Formula1:= _ "=AND($A2<=D$1,$B2>=D$1,$C2=""Normal"")"
Shizx98’s macro was correct, by using R1C1 expression
[此贴子已经被作者于2008-5-18 22:19:25编辑过] |