+ Reply to Thread
Results 1 to 8 of 8

3+ Conditional Formatting Rules for cell range based on Formula from other cells

  1. #1
    Registered User
    Join Date
    02-04-2013
    Location
    texas
    MS-Off Ver
    Excel 2003
    Posts
    4

    3+ Conditional Formatting Rules for cell range based on Formula from other cells

    Hi,
    I've spent a few days trying to figure out how to apply conditional formatting via VBA to a range of cells based on input from another range of cells. Obviously this would be easy in Excel 2010, but I'm still using 2003 at the office and it needs to stay in this format to be readable by other users:

    For cells M8:EK8, my conditional formatting
    condition 2: Formula Is =AND($E$8>=M2,(($E$8-$D$8)>=(N2-$M$2))), color index is 40
    condition 3: Formula Is =AND($F$8<=M2,$G$8>=M2), color index is 39
    I want to add:
    condition 4: Formula Is =AND($H$8<=M2,$I$8>=M2), color index is 40
    condition 5: Formula Is =AND($J$8<=M2,$K$8>=M2), color index is 39
    and so on

    The cells in the range M8:EK8 are blank, they only get colored based on input added to D8 to K8. If there is no input, then the cells should be uncolored.

    resource tracking ex.jpg

    Any help is greatly appreciated!

    -Sarah

  2. #2
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: 3+ Conditional Formatting Rules for cell range based on Formula from other cells

    hi Sarah, wlecome to Excelforum, you could use the following formula:

    OR(AND(cond1,cond2),AND(cond3,cond4)) then color index is 40

    where:
    cond1: $E$8>=M2
    cond2: ($E$8-$D$8)>=(N2-$M$2)
    cond3: $H$8<=M2
    cond4: $I$8>=M2

    Same for another set of 4 conditions

    PS. As it is Excelforum it would be logical to provide mock up of a workbook. You would have much more chances to get replies

  3. #3
    Registered User
    Join Date
    02-04-2013
    Location
    texas
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: 3+ Conditional Formatting Rules for cell range based on Formula from other cells

    Thanks watersev,
    I'm unsure how to translate this formula into VB wording. I can't use conditional formatting as I only get 3 rules
    Inst Use Tracking ex.xls

  4. #4
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: 3+ Conditional Formatting Rules for cell range based on Formula from other cells

    I'm not sure I understand what you expect from me to do with the file. Example to add conditional format, formula part:

    Please Login or Register  to view this content.
    Last edited by watersev; 02-05-2013 at 05:52 PM.

  5. #5
    Registered User
    Join Date
    02-04-2013
    Location
    texas
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: 3+ Conditional Formatting Rules for cell range based on Formula from other cells

    Thanks for trying!
    But I've tried that, it won't work.
    I can't combine conditions like in your formula b/c the:
    "AND($E$8>=M2,($E$8-$D$8)>=(N2-$M$2))" --> must return one color (let's say orange)
    "AND($H$8<=M2,$I$8>=M2)" --> must return a different color (let's say red)

    I'm also needing more than the 3 condition limit (I'm working in XLS 2003). I recorded the macro and got the same code to formulate a condition, but if I have more than 3 of these I get an error. So the conditional format limit is hard coded, thus I need to get around it by other means.

    I've tried using code such as:
    Please Login or Register  to view this content.
    **Where I'm having trouble:
    1. This code is based on a cell.value, not cell.formula, HOWEVER The cells I need colored do not have a value or a formula in them, they are blank - but these blank cells are being colored based on a formula that references the values of other cells.
    2. I'm really referencing two ranges (and I don't know how to translate this into VBA) - if the cells in range D8 to K8 apply to the formulas defined, then color cells M8 to EK8 as appropriate based on the formula rules

    So if I try to modify the above code as such:
    Please Login or Register  to view this content.
    It does not work, so I'm not sure what I'm missing
    Last edited by osborsm9; 02-06-2013 at 11:56 AM.

  6. #6
    Registered User
    Join Date
    02-04-2013
    Location
    texas
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: 3+ Conditional Formatting Rules for cell range based on Formula from other cells

    watersev,
    I would like to add your code does work if I keep to two colors. I'm completely silly and just realized I didn't specify one of the code lines to be a different color-index (say 38 instead of 39 or 40). But if I want each formula to yield a different color, then see my previous question.

    And thanks again for your help!

  7. #7
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: 3+ Conditional Formatting Rules for cell range based on Formula from other cells

    Excel 2003 has limitation of 3 conditions for CF. My suggestion was to join conditions under the same color code and thus avoid using VB instead of CF. If your first post request is correct my suggestion should work.
    In the meantime I've made a sample for 4 colors condition, please check attachment, insert start and end date. When both dates are entered and end date is later/equal than/to start date you should get proper highlighting
    Attached Files Attached Files

  8. #8
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,723

    Re: 3+ Conditional Formatting Rules for cell range based on Formula from other cells

    Bob Phillips has a free add-in, CFPlus, that you can download from his site here:

    http://www.xldynamic.com/source/xld.....Download.html

    This gives you up to 30 conditional formats per range, in up to 100 ranges, so it might be worth having a look at that.

    Hope this helps.

    Pete

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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