VBA code - conditional formatting with a formula

Bryhni

New Member
Joined
Nov 15, 2012
Messages
7
My first post here. I have made a lot of VBA code, but without the basic competence of a programmer (being a process engineer) I always tend to paint myself into a corner...

Now here is the deal:
I made some tedious code to construct a FormulaRange (typically=$D$6:$E$357;$H$6:$I$357;$L$6:$L$357;bla bla bla;$DX$6:$DX$357) containing all cells that should have formulas in them. I want all cells that are manually overwritten to be flagged RED.

Code:
With FormulaRange
    .Select
    .FormatConditions.Add Type:=xlExpression, Formula1:="=NOT(IsFormula(" & ActiveCell.Address(False, False) & "))"
    .FormatConditions(1).Font.ColorIndex = 3 '1=black,3=red,5=blue,xlAutomatic
End With
The IsFormula function is stolen from you guys, ref. Excel Conditional Format for cells containg a formula
Code:
Function IsFormula(c)
    IsFormula = c.HasFormula
End Function
The formula looks fine and appears like this: =NOT(IsFormula(D6))
The problem occurred on my office computer with Win XP and Excel 2007: The macro just halts after the formula definition. No error (which also happens to occur when I have a macro insert a row into this spreadsheet when it has conditional formatting rules).
So this leaves me with a perfectly good conditional formatting rule but no formatting set for it. And obviously this is also the last action my macro will perform, which was not my intention.

However, last night I emailed this workbook to my home computer to continue debugging. And: on Win 7 64-bit, Excel 2010 everything works!
Being a lousy programmer, I always cheat my way around parameter declarations etc. It usually works anyway.
Anyone?
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

Forum statistics

Threads
1,215,584
Messages
6,125,670
Members
449,248
Latest member
wayneho98

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