How can I list all of the properties of Conditional Formatting on a cell?

MPW

Well-known Member
Joined
Oct 7, 2009
Messages
571
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I am using Office 2003 in XP.

I would like to capture all the specs of a cell with conditional formatting.
Would I look for each one separately, or is there a way to extract them all at once?
I know how to capture the formulas of each condition but I seem to have a problem with looking for format changes if they do not exist.
Code:
If Range("A1").FormatConditions.Count <> 0 then
   For i = 1 to Range("A1").FormatConditions.Count
      With Range("B1")
         .FormatConditions.Add Type:= _
          Range("A1").FormatConditions(i).Type, _
          Formula1:=Range("A1").FormatConditions(i).Formula1
      end with
   Next i
End If
The code above will create the same formula driven conditions in Cell B1 that exists in Cell A1. What I am looking for are the rest of the components. For instance, if I try this with the font:
Code:
      .FormatConditions(i).Font.Name = _
       Range("A1").FormatConditions(i).Font.Name
It will crash. I am trying not to use an on error statement, I would rather test if each condition is present.

I know that the cell could be copied but I would like to know how to do it this way if possible.

MPW
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
No takers eh,

Well I did work through it and thought I should post what I found.
The biggest mistake I was making was that there is no property for the font name with conditional formatting!

Basically if the property is disabled when you try to manually create the conditional format then you probably can't do it through the code either. I am sure there are ways around it but that would be for another day.

The properties that I did find were:
Code:
With Range("A1").FormatConditions(i).Font
   .Bold
   .Italic
   .Underline
   .ColorIndex
End With
With Range("A1").FormatConditions(i)
   .Interior.ColorIndex
   .Borders.LineStyle
   .Borders.ColorIndex
End With
I also found that there are 2 Types of conditions so I tested to see which one was needed and added the operator if needed.
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,849
Members
452,948
Latest member
UsmanAli786

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