PDA

View Full Version : Using a variable in conditional formating



Djblois
08-29-2006, 02:09 PM
My last row is always different and I would like to do a conditional formating on the last column based on the total of that column. However, I can't figure out how to get the conditional formating to work

Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlLess, Formula1:=finalCell

That is my code and finalCell is my variable.

Zack Barresse
08-29-2006, 03:03 PM
Hi there,

Kind of hard without seeing the rest of your code. Why use Selection? What is finalCell?

Bob Phillips
08-29-2006, 03:39 PM
My last row is always different and I would like to do a conditional formating on the last column based on the total of that column. However, I can't figure out how to get the conditional formating to work

Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlLess, Formula1:=finalCell
That is my code and finalCell is my variable.

How about using a formula that calculates the last cell, maybe a dynamic range formula or something?

Bob Phillips
08-29-2006, 03:47 PM
Looking at your previous post I see that FinalCell does just that.

As such, yoiur code seems to work. The only thing I could think was to delete them first



Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlCellValue, _
Operator:=xlLess, _
Formula1:=finalCell


What difficulty are you having with it?