+ Reply to Thread
Results 1 to 19 of 19

Conditional formatting using formulas

  1. #1
    Forum Contributor
    Join Date
    11-11-2011
    Location
    London, England
    MS-Off Ver
    EXCEL 2013
    Posts
    324

    Conditional formatting using formulas

    Hi guys

    sorry to bother you, but I have been stuck on this particular formula for the last week, and I don’t seem to be progressing any further, and I am hoping you can help


    basically there are 6 columns, within these 6 columns there is two kinds of data. The data will either be a number or –. (-) is meant to show n/a, but for reporting purposes I need it to remain (-)

    what I am trying to achieve with the formula ,

    1)formula searches the multiple columns, and whatever the last number is within those 6 column highlight that particular cell but only highlight the cell if its higher than the average

    so if it take row 7, although E7 is higher than average 11, this shouldn’t be highlighted. However h7 should as it’s the last stage and its over the average

    if I take row 13, g13 currently has a 12 in it, this is higher than the average of 8, once again this shouldn’t be highlighted as there is another stage, h12 should be highlighted red as it’s the last stage and its higher than the average of 21

    row 13, 14 & 15 , column h should be highlighted red as it over 21 day average


    Hope this make sense
    Attached Files Attached Files
    Last edited by masond3; 11-14-2011 at 09:54 AM.

  2. #2
    Registered User
    Join Date
    11-03-2011
    Location
    Shelton, CT
    MS-Off Ver
    Excel 2010
    Posts
    67

    Re: Conditional formatting using formulas

    Here is the modified workbook that includes the conditional formatting.

    I changed the format of the cells to be "Accounting" with zero decimals and no $. This will allow you to enter a zero and it will show a " - ". If you just put in a Dash or an N/A, then your evaluation of numbers will not work properly.

    Optomyst
    Attached Files Attached Files

  3. #3
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Conditional formatting using formulas

    This is perhaps more complicated than what first meets the eye.

    If I read this correctly then my approach would be to create 2 dynamic named ranges

    1/. Name:= "DataRow"
    Refers to:=
    Please Login or Register  to view this content.
    2/. Name:= "Averages"
    Refers to:=
    Please Login or Register  to view this content.
    Then this formula for the C/F
    Please Login or Register  to view this content.
    Applies to:=
    Please Login or Register  to view this content.
    Hope this helps
    Attached Files Attached Files
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  4. #4
    Forum Contributor
    Join Date
    11-11-2011
    Location
    London, England
    MS-Off Ver
    EXCEL 2013
    Posts
    324

    Re: Conditional formatting using formulas

    Optomyst


    thank you for replying, looking at the work sheet you are nearly there, however it should look at all the cells, determine what stage it is at, and should only highlight the last stage it is at, if it has gone over the average. so row 4 5, 6, 8 is incorrect . nothing should be highlighted in that instance

  5. #5
    Forum Contributor
    Join Date
    11-11-2011
    Location
    London, England
    MS-Off Ver
    EXCEL 2013
    Posts
    324

    Re: Conditional formatting using formulas

    Marcol

    Thank you for looking into my excel problem. The excel file you have uploaded, is exactly what i want. You have however lost me with all the formulas and code lol
    The spread sheet that i need to apply this to, currently has 2900 bits of data which will vary every month, if i copy your formula of

    =IF(MATCH(99^99,DataRow,1)=COLUMN(A$1),IF(INDEX(DataRow,1,MATCH(99^99,DataRow,1))>INDEX(Averages,1,MATCH(99^99,DataRow,1)),TRUE,""),"")

    is there anything which I need to do ?

    Also, is it possible if you could do screen prints and steps of how you got to the end solution?

    Sorry to be a pain, however I would appreciate it and it will help me in the long run

    regards

  6. #6
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,717

    Re: Conditional formatting using formulas

    Try this:

    Select range C4:H18 and apply this formula in conditional formatting

    =AND(COUNT(C4:$H4)=1,C4>C$23,ISNUMBER(C4))

    see attached
    Attached Files Attached Files
    Audere est facere

  7. #7
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Conditional formatting using formulas

    I'd gladly explain, but as usual it is far easier to go with daddylonglegs

  8. #8
    Forum Contributor
    Join Date
    11-11-2011
    Location
    London, England
    MS-Off Ver
    EXCEL 2013
    Posts
    324

    Re: Conditional formatting using formulas

    DaddylongLegs

    Thank you for helping me out with this problem. Is it possible if you can explain your formula to me ? Sorry to be a pain but i am just trying to think how can I apply this formula to the spreadsheet that I have.

    For instance my data can vary from 1500 rows to 5000, how can I automatically apply this formula so it grows and shrinks according to the data.

    Currently the other formulas which I have put in the spread sheet I normally put 6000, can I apply that method to this formula ?

  9. #9
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,717

    Re: Conditional formatting using formulas

    Where would the average figures be, will they move too depending on the amount of data?

    Apart from that the formula should work "as is", you just have to change the "Applies to" range to C4:H6000 - blank cells won't be formatted so that shouldn't be a problem

    The formula just checks three things

    =C4>C$23 - the cell value is greater than the average

    =ISNUMBER(C4) - the cell value is a number (because "-" is deemed to be greater than any number)

    =COUNT(C4:$H4)=1 - there's only 1 number in the range from the current cell all the way to the end of the row - given the previous condition that means that the cell value is the last number in the row
    Last edited by daddylonglegs; 11-13-2011 at 01:01 PM.

  10. #10
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,717

    Re: Conditional formatting using formulas

    If the average figures will always be at the bottom, i.e. last number in the row then you can use this version

    =AND(COUNT(C4:$H4)=1,C4>LOOKUP(99^99,C:C),ISNUMBER(C4))

    the LOOKUP part just returns the last number in the column (i.e. the average figure)

  11. #11
    Forum Contributor
    Join Date
    11-11-2011
    Location
    London, England
    MS-Off Ver
    EXCEL 2013
    Posts
    324

    Re: Conditional formatting using formulas

    Hi

    if i remember correctly i used the format table function within excel, so the averages will be fixed at the bottom of the spreadsheet however it should grow or shrink depending on the data, but it always be below the data

    thank u for breaking down the formula, so depending where my data is highlight the body of text

    so for example if my data started from column M and finished at R and started row two
    and my average for column m was on row m2891

    would I put =AND(COUNT(m2:$r2)=1,m2>m$2891,,ISNUMBER(m2))

  12. #12
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,717

    Re: Conditional formatting using formulas

    Yes, that's almost right, but you have an extra comma that will mess up the results, so you need to remove that - should be

    =AND(COUNT(M2:$R2)=1,M2>M$2891,ISNUMBER(M2))

    As per my last post, rather than having to identify the average row you could use LOOKUP to look for the last number in the column, so that would make it

    =AND(COUNT(M2:$R2)=1,M2>LOOKUP(99^99,M:M),ISNUMBER(M2))

    Note that I'm used to selecting the whole range first - that was probably the easiest way in Excel 2003 - but now it's possible to edit the "Applies to" range so I would probably just select the first few rows (must begin at M2) and then edit the "Applies to" range within CF to M2:R2890 or whatever

  13. #13
    Forum Contributor
    Join Date
    11-11-2011
    Location
    London, England
    MS-Off Ver
    EXCEL 2013
    Posts
    324

    Re: Conditional formatting using formulas

    Hi Daddylonglegs


    I tried to apply the formula =AND(COUNT(C4:$H4)=1,C4>C$23,ISNUMBER(C4)) and i have changed all the data fields so that it applies to spreadsheet, however it doesn’t seem to be working correctly

    if i upload my data is it possible if you could apply the formula to the spreadsheet, or tell me what the problem is ?


    Regards

    Masond3
    Last edited by masond3; 11-14-2011 at 07:25 AM.

  14. #14
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,717

    Re: Conditional formatting using formulas

    If you upload the sheet I'll take a look.....

  15. #15
    Forum Contributor
    Join Date
    11-11-2011
    Location
    London, England
    MS-Off Ver
    EXCEL 2013
    Posts
    324

    Re: Conditional formatting using formulas

    Hi

    Please find attached spreadsheet which I am trying to apply this to

    The columns which it should apply to are “R– V” from row 2 down to 2862
    and the average row sits on row 2863 underneath the columns

    hope this helps

    (reason why spreadsheet not attaching is because it over file size limit) i have to zip it up, so i am hoping this should of worked now )
    Attached Files Attached Files
    Last edited by masond3; 11-14-2011 at 08:13 AM.

  16. #16
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,717

    Re: Conditional formatting using formulas

    Seemed to work OK for me. I applied the formula first to a single row, so I selected just R2:V2 and used this formula in conditional formatting

    =AND(COUNT(R2:$V2)=1,R2>R$2863,ISNUMBER(R2))

    Then I changed the "Applies to" range from =$R$2:$V$2 to =$R$2:$V$2862 and then I got formatting as expected, see attached
    Attached Files Attached Files
    Last edited by daddylonglegs; 11-14-2011 at 08:28 AM.

  17. #17
    Forum Contributor
    Join Date
    11-11-2011
    Location
    London, England
    MS-Off Ver
    EXCEL 2013
    Posts
    324

    Re: Conditional formatting using formulas

    Hi

    it doesn’t seem to work for me
    i am assuming the formula should be =AND(COUNT($R$2:$V$2862)=1,R2>R$2863,ISNUMBER(R2))

    I have done conditional formatting , highlighted row R2 down to row V2862

    then go to conditional formatting tab, manage rules

    show formatting rules for : this table

    and still nothing is highlighted

    Thank you for sending back your version, i just cnt grasp where i am going wrong


    ******** update **********

    looking at your example , your formula is =AND(COUNT(R2:$V2)=1,R2>R$2863,ISNUMBER(R2))

    and i put =AND(COUNT($R$2:$V$2862)=1,R2>R$2863,ISNUMBER(R2))

    i take it, that the part after the count, is the reason why its not working ?
    Last edited by masond3; 11-14-2011 at 08:46 AM.

  18. #18
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,717

    Re: Conditional formatting using formulas

    Yes, it needs to be the version I suggested - the COUNT part only looks at a single row. The formula doesn't need to be adjusted based on the number of rows - you just need to apply that same formula to a larger range. Excel will automatically adjust so that it looks at each individual row within the range you specify

  19. #19
    Forum Contributor
    Join Date
    11-11-2011
    Location
    London, England
    MS-Off Ver
    EXCEL 2013
    Posts
    324

    Re: Conditional formatting using formulas

    Agh Okay

    i see where i went wrong now. thank you for taking your time to have a look at this for me. It is truly appreciated

+ 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