+ Reply to Thread
Results 1 to 11 of 11

code for deleting existing conditional rules and reapplying them back

  1. #1
    Registered User
    Join Date
    05-06-2013
    Location
    toronto,Canada
    MS-Off Ver
    Excel 2010
    Posts
    75

    code for deleting existing conditional rules and reapplying them back

    Hi, I have a spreadsheet with 2 workbooks and in each workbook, there are a few conditional formatted columns. What I would like to do is have a macro that: 1) clears the existing cond. formats. 2)reapply those formats back on to the cells.

    The attached file described where the cond. formats are applied. The first workbook contains cond. formats in column N,PQRST(same conditions for pqrst), and column O in the second workbook.

    I am ok with having 2 macros: 1 to delete exisiting conditional rules(thereby getting rid of the colors)
    2 to reapply the same cond format(reapply color)

    Keep in mind that the number of rows could potentially increase at a later date, but the formatting will essentially stay the same. I just dont want the rule to be applied to 4983049288 cells, only the non empty cells.

    Thank you in advance for your help!
    Attached Files Attached Files
    Last edited by hk4kim; 07-29-2013 at 02:18 PM. Reason: no one is helping so i'm closing the thread

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,705

    Re: code for deleting existing conditional rules and reapplying them back

    Quote Originally Posted by hk4kim View Post
    What I would like to do is have a macro that: 1) clears the existing cond. formats. 2)reapply those formats back on to the cells.
    This makes no sense to me so I must not understand what you're trying to do. Why would you want a macro the deletes conditional formats, then re-creates them?

    Do you mean that you want to delete the conditional formatting and use the results of the conditional formatting as permanent formatting? For example, if a cell is less than 7 and has a red fill, remove the conditional format and change the cell to have red fill formatting?

    I am also curious as to why you want to do this--there might be another way to approach your overall problem.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    05-06-2013
    Location
    toronto,Canada
    MS-Off Ver
    Excel 2010
    Posts
    75

    Re: code for deleting existing conditional rules and reapplying them back

    6StringJazzer,
    Hi, it has to do with the fact that some people who work with this file have a hard time editting data because the conditional formats are the result of slow processing time. Once they are removed, the file works smoothly. However, because they need to be present at the end, the cond. formats rules have to be reapplied afterewards.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    What conditional formatting are you using and what range(s) is it applied to?
    If posting code please use code tags, see here.

  5. #5
    Registered User
    Join Date
    05-06-2013
    Location
    toronto,Canada
    MS-Off Ver
    Excel 2010
    Posts
    75

    Re: code for deleting existing conditional rules and reapplying them back

    Norie,
    they are explained in my OP under my attached file and they are just simple "greater than", "less than" rules.

  6. #6
    Registered User
    Join Date
    05-06-2013
    Location
    toronto,Canada
    MS-Off Ver
    Excel 2010
    Posts
    75

    Re: code for deleting existing conditional rules and reapplying them back

    Norie,
    they are explained in my OP under my attached file and they are just simple "greater than", "less than" rules.
    Last edited by hk4kim; 07-26-2013 at 01:23 PM.

  7. #7
    Registered User
    Join Date
    05-06-2013
    Location
    toronto,Canada
    MS-Off Ver
    Excel 2010
    Posts
    75

    Re: code for deleting existing conditional rules and reapplying them back

    Help/suggestions are greatly appreciated

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: code for deleting existing conditional rules and reapplying them back

    Are you sure the conditional formatting is what's slowing things up?

    You've only applied it to 1138 cells, and the conditions are pretty simple.

  9. #9
    Registered User
    Join Date
    05-06-2013
    Location
    toronto,Canada
    MS-Off Ver
    Excel 2010
    Posts
    75

    Re: code for deleting existing conditional rules and reapplying them back

    Yes, I've tested several times with and without them.

  10. #10
    Registered User
    Join Date
    05-06-2013
    Location
    toronto,Canada
    MS-Off Ver
    Excel 2010
    Posts
    75

    Re: code for deleting existing conditional rules and reapplying them back

    bump for help

  11. #11
    Registered User
    Join Date
    06-26-2013
    Location
    Northern Ireland
    MS-Off Ver
    Excel 2003, 07, 10
    Posts
    92

    Re: code for deleting existing conditional rules and reapplying them back

    This code below deletes the condtional formatting in the Range that I am using and then applies the conditional formatting again. It might not be exactly what you are looking for but I hope it will at least help you out. I have declared my variables as Doubles as the numbers I was formatting were in a percentage format to begin with. So -0.03 is -3% and 0.5 is positive 50%

    Formula: copy to clipboard
    Please Login or Register  to view this content.

+ 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. Replies: 3
    Last Post: 07-17-2013, 06:14 PM
  2. Deleting rows without conditional formatting
    By ShawnaC in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-11-2013, 02:38 PM
  3. conditional Formatting based on existing formatting
    By jomili in forum Excel General
    Replies: 18
    Last Post: 02-18-2011, 10:17 AM
  4. Conditional Formatting Fails after Deleting Column
    By k777 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-22-2010, 08:28 PM
  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

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