+ Reply to Thread
Results 1 to 8 of 8

Conditional Formatting - Multiple Rules Per Range (Macro) Help Please!

  1. #1
    Registered User
    Join Date
    09-12-2013
    Location
    New Zealand
    MS-Off Ver
    Excel 2011
    Posts
    5

    Conditional Formatting - Multiple Rules Per Range (Macro) Help Please!

    Hey all,

    I've recently created an Excel sheet with a bunch of conditional formatting to detect incorrect/suspicious entries, etc.
    Unfortunately I ran into issues with Excel splitting the conditional formatting ranges when people inserted rows and copied data (http://stackoverflow.com/questions/1...ing-insert-row - Similar Problem).

    Ultimately, my solution is to have a macro to delete all conditional formatting, and then re-insert it, this will fix my issues.

    I'm having problems applying multiple rules to a single range.
    I'm not a VisualBasic native (yet) - so it is probably something really basic.

    Please Login or Register  to view this content.
    This code basically detects for columns A and B, if there is a value in the next cell, and highlights the cell blue if it is empty. (i.e. If A1 is blank, but B1 is not, A1 should be blue as an error warning).

    I run into issues with the two conditional formats on a single range. As you can see, I have two in there for the column B range, but only one of them will work at a time. Both formulas are valid, but Excel uses the first and ignores the second. (Note: The difference in the formulas is the "RC[-1]" and the "RC[1]" - which changes the cell it is 'watching' from left, to right)


    I have multiple conditional formats on single ranges, so I need to know:

    How can I set multiple conditional formats on a single range - without secondary format rules being ignored?


    I really appreciate your help, it is great to be here and I look forward to learning more!
    Thanks!
    Last edited by brendanh; 09-12-2013 at 07:26 AM.

  2. #2
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,594

    Re: Macros: Conditional Formatting

    For the Range("B8:B1048576") both the formulas are same.

  3. #3
    Registered User
    Join Date
    09-12-2013
    Location
    New Zealand
    MS-Off Ver
    Excel 2011
    Posts
    5

    Re: Macros: Conditional Formatting

    Quote Originally Posted by kvsrinivasamurthy View Post
    For the Range("B8:B1048576") both the formulas are same.
    Thanks for taking the time to check it out. As per OP
    '(Note: The difference in the formulas is the "RC[-1]" and the "RC[1]" - which changes the cell it is 'watching' from left, to right)'

  4. #4
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,594

    Re: Conditional Formatting - Multiple Rules Per Range (Macro) Help Please!

    Try this code.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    09-12-2013
    Location
    New Zealand
    MS-Off Ver
    Excel 2011
    Posts
    5

    Re: Conditional Formatting - Multiple Rules Per Range (Macro) Help Please!

    Great - that works perfectly! I'm guessing it comes down to the ".FormatConditions(Range("B8:B10").FormatConditions.Count).SetFirstPriority"
    Can I ask what exactly this does?

  6. #6
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,594

    Re: Conditional Formatting - Multiple Rules Per Range (Macro) Help Please!

    I guess that this command sets the priorirty for CF. If no priority is set only one condition will be accepted.

    I request experts to explain more about this.

  7. #7
    Registered User
    Join Date
    09-12-2013
    Location
    New Zealand
    MS-Off Ver
    Excel 2011
    Posts
    5

    Re: Conditional Formatting - Multiple Rules Per Range (Macro) Help Please!

    And of course today I run into more issues!
    When I try to run my format macro

    Run-time error '1004':
    Application-defined or object-defined error.

    I've put asterisks on the lines that are highlighted by the debugger.
    I can't for the life of me figure out what is wrong - this used to work!

    Any thoughts?

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    09-12-2013
    Location
    New Zealand
    MS-Off Ver
    Excel 2011
    Posts
    5

    Re: Conditional Formatting - Multiple Rules Per Range (Macro) Help Please!

    Ah - this had to do with me activating protection on the workbooks.
    Is there any way to have protection, but allow validation edits?

+ 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. [SOLVED] Help with Macros and/or Conditional Formatting.
    By Inez15 in forum Excel General
    Replies: 5
    Last Post: 11-08-2012, 01:11 PM
  2. Conditional formatting and macros.
    By johnfar in forum Excel General
    Replies: 0
    Last Post: 12-15-2011, 09:41 AM
  3. Conditional Formatting Macros
    By njadam in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-22-2011, 02:58 AM
  4. Formatting conditional columns with macros
    By copleyr in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-22-2009, 11:23 PM
  5. Conditional Formatting And Macros
    By Dominic_Hodgson in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-04-2007, 05:33 AM

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