Question : Hopefully simple question... "locking" conditional formating

When I set up my conditional formating, I use the RANGE of =$A$3:$0$1044644
However, after a while (due to cuts and pastes I guess), it becomes a fragments mess like:
=$A$210:$N$213,$A$2:$N$208,$A$215:$I$1044644,$K$215:$N$1044644,$J$215:$J$469,$J$472:$J$1044644

How can I prevent this from happening? We still need to cut and paste data from other sources.
Or is there a way I can "recreate" the ranges on OPEN? (As far as I know, you cant manipulate conditional formating, I am not sure if anything is diffent is 2007 that allows you to though...)

Thanks!
Bruj

Answer : Hopefully simple question... "locking" conditional formating

Hi Bruj,

I studied the problem and discovered new and amazing thing for me. Never before I've met a task where there was necessary to use Activecell.
I found that when we assign Formula to the Format Condition, it is translated as if being applied to the Activecell. So if we've composed a formula for the top left cell of CF range (assuming that it has proper relative/absolute references to be expanded over the range) we must set Activecell to the top left cell of CF range. The easiest way to do this is to select the CF range. So you were right in general about selection.

I hope that this macro is suitable for you.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
Private Sub Workbook_Open()
Dim lastRow As Long
With Worksheets("Sheet1")
    .Cells.FormatConditions.Delete  'DELETE ALL COND FORMATTING
    lastRow = .Rows.Count
    With .Range("A3:O" & lastRow)   'SET default object, all expressions starting with
                                    '"." will refer to it. Note nested "With"
        .Select                     'to set ActiveCell to top left corner of the range
        .FormatConditions.Add Type:=xlExpression, Formula1:="=COUNTIF($E$3:$E3,$E3)>1"
        .FormatConditions(1).Interior.ColorIndex = 44
        .FormatConditions(1).StopIfTrue = True
        .FormatConditions.Add Type:=xlExpression, Formula1:="=COUNTIF($E$3:$E$" & lastRow & ",$E3)>1"
        .FormatConditions(2).Interior.ColorIndex = 37
        .FormatConditions.Add Type:=xlExpression, Formula1:="=UPPER($K2) = ""YES"""
        .FormatConditions(3).Interior.Color = vbRed    'Red
    End With
End With
End Sub
Random Solutions  
 
programming4us programming4us