conditional formating "extension problems" HELP!!

brink

New Member
Joined
Nov 3, 2002
Messages
41
Here is my problem. I need to some how add several more conditional formatting options. I have tried to add all different kinds of VB to solve my problem but none of them seem to work. The one below is my favorite – but doesn’t work with my formulas. I have formulas returning different values. I need this program below (our one like it) to be “formula friendly”. When the formula result changes - I need the colors to change as well. This program doesn’t work with “if” formulas and will not reset itself when returning another cell’s values – it will work on the first returned value – but then after – “freezes up”.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim x As Variant

Count = 0
Do Until Count = 12
If Target.Value = Range("A1").Offset(Count, 0).Value Then
x = Range("A1").Offset(Count, 0).Interior.ColorIndex
End If
Count = Count + 1
Loop

Target.FormatConditions.Delete
Target.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:=Target
Target.FormatConditions(1).Interior.ColorIndex = x

End Sub
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
The Worksheet_Change event fires when data is entered by the user, not by recalculation of formulas.

What range of cells do you wish to format?
 
Upvote 0
That's quit a big range - better make sure calculation is set to manual!

Code:
Private Sub Worksheet_Calculate()
    Dim c As Range
    Dim Count As Integer
    Dim x As Variant
    On Error GoTo NoFormulas
    For Each c In Range("Z5:IJ80").SpecialCells(xlCellTypeFormulas)
        Count = 0
        x = ""
        Do Until Count = 12
            If c.Value = Range("A1").Offset(Count, 0).Value Then
                x = Range("A1").Offset(Count, 0).Interior.ColorIndex
                Exit Do
            End If
            Count = Count + 1
        Loop
        If x <> "" Then
            c.FormatConditions.Delete
            c.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
            Formula1:=c
            c.FormatConditions(1).Interior.ColorIndex = x
        End If
    Next c
NoFormulas:
End Sub
 
Upvote 0
As it is such a Large Range is it possible to select cells where the value is greater than 0 rather than using
For Each c In Range("F3:IB100").SpecialCells(xlCellTypeFormulas)

would this way calculate any faster
 
Upvote 0

Forum statistics

Threads
1,214,415
Messages
6,119,377
Members
448,888
Latest member
Arle8907

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