+ Reply to Thread
Results 1 to 7 of 7

Conditional Format based on a Cell Reference

  1. #1
    Forum Contributor
    Join Date
    10-13-2015
    Location
    Culloden, West Virginia
    MS-Off Ver
    2010
    Posts
    168

    Conditional Format based on a Cell Reference

    What I'm trying to do:
    Turn a cell a specific color based on a formula. Example: if the sum(R37:T37)=O37 then format R37:T37 as Green Fill

    The Problem:
    O37 is a number based on a calculation that gives me a decimal. I require my numbers to be in tenths, so I have the cell formatted to only show me one decimal place. The numbers that are in R37:T37 are manually entered (in tenths). So, if O37 shows me 2.8, I may have entered 1.4, 1, .4 in R37:T37, the conditional format will not necessarily kick in because O37 is likely a different number like 2.754321.

    My Question:
    Is it possible to get my formula to look at a reference number as a rounded number?

  2. #2
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: Conditional Format based on a Cell Reference

    hi there. select the range you want to apply to (say from R37:T37)
    go to Home tab -> Conditional Formatting -> New Rule -> Use a formula to determine which cells to format -> Format values where this formula is true:
    =SUM($R$37:$T$37)=ROUND($O$37,1)

    format the cells to the desired color.

    next time though, do upload an excel sample so that we do not have to manually key in your data to do a testing.

    input the desired results so that we don't have to second-guess if what we are doing is correct or not. you may look at my signature to upload an eg that is easier to understand.

    the upload attachment must be done by going to Go Advanced. click on Manage Attachments. Choose file, upload and close the window.

    if i really guessed it wrongly, please upload something according to my recommendations. try to use the solution i have given and we'll help to advise what went wrong.
    Attached Files Attached Files

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  3. #3
    Forum Contributor
    Join Date
    10-13-2015
    Location
    Culloden, West Virginia
    MS-Off Ver
    2010
    Posts
    168

    Re: Conditional Format based on a Cell Reference

    Thank you ben, you did exactly what I requested. The only issue I had with it was whenever the value of O37 was 0, the conditional format kicked in.
    I only wanted it to apply if I input data in R37:T37. I corrected that with this in the conditional formula =IF(O37=0,,SUM(R37:T37)=ROUND(O37,1))

    Also, you can see I removed the absolute reference so that I can copy the conditional formula through the entire column that I need it, but after do that
    the conditional format only works on R37. I can't seem to correct that.

    I've attached the actual file this time. The data that I'm working with is R11:T740 which will be referencing O11:O740
    Attached Files Attached Files

  4. #4
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: Conditional Format based on a Cell Reference

    remove all your previous conditions. select the range you want to apply to (say from R11:T740)
    go to Home tab -> Conditional Formatting -> New Rule -> Use a formula to determine which cells to format -> Format values where this formula is true:
    =AND(SUM($R11:$T12)=ROUND($O11,1),$O11<>0)

    i am fixing the columns to reference to, but not the rows. that is so that it can be applicable for all the rows you need.

  5. #5
    Forum Contributor
    Join Date
    10-13-2015
    Location
    Culloden, West Virginia
    MS-Off Ver
    2010
    Posts
    168

    Re: Conditional Format based on a Cell Reference

    Brilliant, Sir.

    Do you understand why the conditional formatting was behaving the way it was by using the original formula? I couldn't understand why making a cell relative vs. absolute would change the outcome.

  6. #6
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: Conditional Format based on a Cell Reference

    when you say "original" formula, do you mean mine or the one you amended? with my formula:
    =SUM($R$37:$T$37)=ROUND($O$37,1)
    i fixed all the columns and rows, so it will always compare the same cells. it was based on your description and i lazily fixed everything since that is the 1st option when you press the F4 key. if you don't know this, you can actually press F4 to add dollar signs to your cell reference when you are doing formulas. for eg, type in cell A1:
    =b10
    press F4 and you'll see:
    =$B$10
    press F4 again and you'll have:
    =B$10
    and it goes on for a total of 4 different variations.

    if you are talking about the formula you used:
    =IF(O37=0,,SUM(R37:T37)=ROUND(O37,1))
    i actually talk about this in my Excel training classes. but it'll be harder here without the visuals. try and imagine conditional formatting working behind the cells.
    1. i mentioned to select from cell R11. forgot to underline it in my previous post but this is very important.
    2. when you get to the New Formatting Rule window via Home tab -> Conditional Formatting -> New Rule -> Use a formula to determine which cells to format, notice that it requires just a single formula.

    now, the formula you placed in point 2 will be placed in the cell you selected in point 1 (in the backend). you can do a simulation in cell AB11 for eg. simply type the formula you used:
    =IF(O11=0,,SUM(R11:T12)=ROUND(O11,1))
    so imagine this cell is actually R2. the conditional formatting drags this formula across and below (R11:T740). in our simulation, just drag across to AD11 and below to AD14.
    you will see a bunch of TRUEs, FALSEs, and 0s. the TRUEs will format the cell. FALSEs and 0s will not. why did AC11 become FALSE? if you did not fix the cells, dragging the formula from AB11 to AC11 will change the cell referencing. you are now comparing if P11 (wrong cell) equals 0, put 0. otherwise, check if sum of S11:U11 (wrong cells) is equals to rounding to 1 decimal of P11 (wrong cell).

    you could still use the IF formula though. i just didn't see a need. all the conditional formatting requires is TRUE or FALSE. but if you fix the columns, it still works:
    =IF($O11=0,,SUM($R11:$T12)=ROUND($O11,1))

    by the way, don't merge cells if unnecessary. in your case, it just seems like you need the row a little wider. simply adjust the row height.

    hope that helps.

  7. #7
    Forum Contributor
    Join Date
    10-13-2015
    Location
    Culloden, West Virginia
    MS-Off Ver
    2010
    Posts
    168

    Re: Conditional Format based on a Cell Reference

    Thank you Sir. Very helpful. I truly appreciate you taking the time to assist me and helping me understand the solution.

+ 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. Conditional format reference own cell?
    By kunkka in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-07-2017, 06:05 PM
  2. [SOLVED] VBA macro to format a range of cells based on value of reference cell
    By fotografer in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-28-2017, 05:54 AM
  3. [SOLVED] [B]Conditional Format How to Increment a cell reference[/B]
    By Vassellorry in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 07-10-2016, 07:47 PM
  4. [SOLVED] how to format a cell based on the data reference in another worksheet
    By divi123 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 01-13-2014, 04:47 AM
  5. Automating conditional formatting based on > or < cell reference
    By monalisasmiler in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-13-2012, 10:00 AM
  6. Replies: 5
    Last Post: 02-04-2011, 04:48 PM
  7. [SOLVED] Conditional format from a reference cell?
    By oopsie poopsie in forum Excel General
    Replies: 4
    Last Post: 02-15-2006, 11:30 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