+ Reply to Thread
Results 1 to 9 of 9

How to record/list all existing Conditional Formatting in a worksheet

  1. #1
    Registered User
    Join Date
    05-21-2014
    Posts
    92

    How to record/list all existing Conditional Formatting in a worksheet

    Note: I am using Excel 2010

    First, this is what I have figured out is possible to do:

    1) Developer Tab - "Record Macro"
    2) Home Tab - Conditional Formatting - Manage Rules...
    3) Change "Current Selection" to "This Worksheet"
    4) Click inside the Applied Range field of one of the rules. (A simple click, no typing!)
    5) Click "OK" to exit.
    6) Developer Tab - "Stop Recording"

    The recorded macro now lists all of the conditional formatting code that is applied on the worksheet. With some tweaking, the code can be used to reapply the conditional formatting rules back onto the worksheet.

    What I want to figure out is if it is possible to make a macro that can "record" all of the conditional formatting on a worksheet (like above) and list those rules out on a separate worksheet within the same workbook?

    Currently all I can do is the above recording of the macro and then manually opening and copy-pasting the generated code to a new worksheet. I'm thinking I can use this new worksheet as a basis to re-apply conditional formatting whenever I have to remove formatting during the use of other macros. But it would be nice to be able to automate this part of the process.

    To be clear, I do not want to replace conditional formatting rules with VBA code equivalents.
    Also, I will be gone on a business trip for this week, so I will be only able to check things out on Friday night. Apologies for not being here to clarify any confusion this question may generate.

    Thank you,

    Monimonika
    Last edited by Monimonika; 06-15-2014 at 05:35 PM.

  2. #2
    Valued Forum Contributor fredlo2010's Avatar
    Join Date
    07-04-2012
    Location
    Miami, United States
    MS-Off Ver
    Excel 365
    Posts
    762

    Re: How to record/list all existing Conditional Formatting in a worksheet

    Hi monika are your conditional formatting more or less all the same ? For example are they duplicates values, less than values, contains text values...?

    And yes this can be done.

    Thanks

  3. #3
    Registered User
    Join Date
    05-21-2014
    Posts
    92

    Re: How to record/list all existing Conditional Formatting in a worksheet

    Hi fredlo2010!

    Pretty sure I'm not answering your question correctly, but I would have to say there are two types of conditional formatting rules I use. They are the "Use a formula to determine which cells to format" and "Format only cells that contain" types.

    The vast majority is the former type with custom formulas, since I typically use them to highlight when a cell's value is different from expected based on calculations from other relative cells. For example, if the quantity of an item today is different from what was expected given yesterday's starting quantity and usage.

    These formulas tend to be a bit complicated, as I avoid using relative cell references and instead use INDEX(range,ROW()+r,COLUMN()+c) to refer to all relative cells, including the starting cell. This makes it much easier for me to keep track of and fix any splitting of the conditional formatting rules without having to worry about matching the relative cells to the correct ranges in the formulas.

    ETA: Also, the cells in the applied range are typically not adjacent to each other.
    ETA2: Another usage I have is for changing the font color of cells depending on if cells relative to them fulfill three criteria.
    Last edited by Monimonika; 06-15-2014 at 06:48 PM.

  4. #4
    Valued Forum Contributor fredlo2010's Avatar
    Join Date
    07-04-2012
    Location
    Miami, United States
    MS-Off Ver
    Excel 365
    Posts
    762

    Re: How to record/list all existing Conditional Formatting in a worksheet

    Hi Monika,

    Ok look at the code I have. This is not the final work and most likely it will not work properly yet, but I think I will give you the idea of how to proceed. Basically I am going through each conditional formatting that you have in the sheet and storing as much relevant information as I can so I can later on use it again. I would highly recommend to switch all conditional formatting to formula based ones to reduce complexity.


    Please Login or Register  to view this content.
    Thanks I hope this helps.

  5. #5
    Registered User
    Join Date
    05-21-2014
    Posts
    92

    Re: How to record/list all existing Conditional Formatting in a worksheet

    I'm back from my trip!
    Thank you for the code, fredlo2010!

    I will try studying it and testing parts of it out. It will take a while since I'm slow and will likely be distracted by other things, but I'm already learning more code just from reading what you've provided.

    Grateful,

    Monimonika

  6. #6
    Valued Forum Contributor fredlo2010's Avatar
    Join Date
    07-04-2012
    Location
    Miami, United States
    MS-Off Ver
    Excel 365
    Posts
    762

    Re: How to record/list all existing Conditional Formatting in a worksheet

    no thanks to you Monica. I will implement this code in one of my spreadsheets

  7. #7
    Registered User
    Join Date
    05-21-2014
    Posts
    92

    Re: How to record/list all existing Conditional Formatting in a worksheet

    fredlo2010,

    I finally got around to actually trying out your code in full (told you I was slow) and it works perfectly!! Now I just need to adjust all of my conditional format rules to formula-based ones and I am set!

    Thread is now marked as SOLVED.

  8. #8
    Valued Forum Contributor fredlo2010's Avatar
    Join Date
    07-04-2012
    Location
    Miami, United States
    MS-Off Ver
    Excel 365
    Posts
    762

    Re: How to record/list all existing Conditional Formatting in a worksheet

    you are welcome monika. I am glad I was able to help. I am surprised it worked in the first shut it seemed to me it was not going to be the last product.

    If you modify anything please post the code so others an benefit from it.

    Regards.

  9. #9
    Registered User
    Join Date
    01-19-2012
    Location
    Bedford, England
    MS-Off Ver
    2016 / 365
    Posts
    2

    Re: How to record/list all existing Conditional Formatting in a worksheet

    In case anybody comes across this thread and has more than a few conditional formats or a large sheet, the speed can be considerably improved with
    Please Login or Register  to view this content.
    before the
    Please Login or Register  to view this content.
    line. This will prevent the application visibly switching between worksheets. Remember to turn it back on again with
    Please Login or Register  to view this content.
    . I also set calculation to Manual to prevent constant re-calculation of the target sheet.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Record Macro with IF statements from conditional formatting.
    By ja489 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-20-2013, 02:43 PM
  2. Replies: 3
    Last Post: 07-17-2013, 06:14 PM
  3. Overwrite existing record
    By bryan1706 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-09-2012, 11:15 AM
  4. conditional Formatting based on existing formatting
    By jomili in forum Excel General
    Replies: 18
    Last Post: 02-18-2011, 10:17 AM
  5. Insert a new condition before existing conditional formatting conditions
    By wotadude in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-12-2009, 04:33 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1