Solved

VBA to return the details of condtional formatting

Posted on 2014-09-22
1
135 Views
Last Modified: 2014-09-23
I have two questions,

is it possible to have a vba code that lists all of the condtional formatting range and its condtional formula in a workbook?

secondly, how to set condtional formatting using vba.

for example in SELECTION OF range A1:A20  i want to set the formula =COUNTIFS($B$1:$B$20,$A1) in the condtional formatting to highlight it in yellow if the condtion is met.

appreciate your help.
0
Comment
Question by:ProfessorJimJam
1 Comment
 
LVL 43

Accepted Solution

by:
Steve Knight earned 500 total points
ID: 40338440
Sure, something like this should do it... if it has to work with existing conditional formatting entries or not you might not need/want to clear existing conditions etc.

Steve

 
With Range("A1:A20")
        .FormatConditions.Delete
        .FormatConditions.Add Type:=xlExpression, Formula1:="=COUNTIFS($B$1:$B$20,$A1)"
        .FormatConditions(1).SetFirstPriority
        .FormatConditions(1).Interior.Color = 65535
        .FormatConditions(1).StopIfTrue = False
    End With

Open in new window


For Each objFC In Range("A1:A20").FormatConditions
       Debug.Print objFC.Type, objFC.Interior.Color, objFC.Formula1
Next

Open in new window

0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvieā€¦
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question