Hard code conditional?

Trikageon

Board Regular
Joined
Apr 29, 2010
Messages
51
Is there a way to hardcode the results of a conditional format? For example, I have 2 columns of data that I'd like to hard code the borders produced by conditional formatting. I tried copying the columns, doing a paste special, and then selecting "formats," but that didn't work.

As an alternative, if anyone knows of an if/then formula that would return borders around a cell, that would work too, assuming copying, doing a paste special, and selecting formats would also keep those in place. Thanks in advance!
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
I record a conditional format and get this :-
Code:
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 17/05/2010 by Brian
'
'
    Selection.FormatConditions.Delete
    Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
        Formula1:="0"
    With Selection.FormatConditions(1).Borders(xlLeft)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    With Selection.FormatConditions(1).Borders(xlRight)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    With Selection.FormatConditions(1).Borders(xlTop)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    With Selection.FormatConditions(1).Borders(xlBottom)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With
    Selection.FormatConditions(1).Interior.ColorIndex = 36
End Sub
 
Upvote 0
I'm not sure you're understanding my dilemna. I have a worksheet, and within that worksheet there are cells that are formatted a certain way because they have met certain criteria specified using conditional formatting.

Now, as-is, as soon as the data changes - the formatting will change. I don't want that. I want to, in effect, "hard code" the formatting the way it is now, so that now when the data changes, the formatting doesn't.

Hopefully that makes things more clear!
 
Upvote 0
That definitely seems like it's going in the right direction, however, I'm getting an error on a portion of the code that reads:

If CDbl(rng.Value) = CDbl(FC.Formula1) Then

Also, it seems to be wanting me to point to a particular cell, instead of a range. For clarification, I'd like to hard-code the conditional formatting for columns G:H. Do you have any insight you could offer?
 
Upvote 0
For a non-VBA solution check out the following:
http://www.mrexcel.com/forum/excel-...coding-conditional-formating.html#post3330379

Basically do the following
--make a temporary table with the conditional formula, putting out text or a number {=if(A1=0,"A",1)}

--select all text within the table (Go To, Special, Formulas--Text only)

--Excel will select all the cells that have A (that meet whatever criteria you put in the formula)
--select whatever format you want--it will be applied to each "A" cell

--voila! Hard coded formatting
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top