+ Reply to Thread
Results 1 to 17 of 17

Conditional formatting based on multiple conditions

Hybrid View

bjvick Conditional formatting based... 12-01-2010, 11:05 AM
Palmetto Re: Conditional formatting... 12-01-2010, 01:15 PM
bjvick Re: Conditional formatting... 12-01-2010, 02:35 PM
bjvick Re: Conditional formatting... 12-02-2010, 10:22 AM
bjvick Re: Conditional formatting... 12-03-2010, 10:15 AM
watersev Re: Conditional formatting... 12-03-2010, 11:08 AM
bjvick Re: Conditional formatting... 12-03-2010, 12:19 PM
bjvick Re: Conditional formatting... 12-03-2010, 12:27 PM
arthurbr Re: Conditional formatting... 12-03-2010, 10:46 AM
arthurbr Re: Conditional formatting... 12-03-2010, 01:48 PM
bjvick Re: Conditional formatting... 12-03-2010, 04:12 PM
watersev Re: Conditional formatting... 12-03-2010, 04:36 PM
bjvick Re: Conditional formatting... 12-03-2010, 05:03 PM
watersev Re: Conditional formatting... 12-03-2010, 05:30 PM
bjvick Re: Conditional formatting... 12-03-2010, 05:53 PM
watersev Re: Conditional formatting... 12-03-2010, 06:43 PM
bjvick Re: Conditional formatting... 12-03-2010, 07:05 PM
  1. #1
    Registered User
    Join Date
    11-29-2010
    Location
    Milwaukee, WI
    MS-Off Ver
    Excel 2003
    Posts
    19

    Conditional formatting based on multiple conditions

    I am using a spreadsheet to track machine downtimes at a large manufacturing plant. The machines are identified by a four digit number and are listed in column D and their respective downtimes are in column F. I would like to set the spreadsheet up so that if the same machine is down for a certain amount of time (say 16 hrs) all the rows which contain that machines 4 digit number are highlighted yellow and if the machine is down for 20 hours the rows are highlighted red. The spreadsheet may possibly be tracking hundreds of machines so if there is a way for a macro to automatically look at entries with the same 4 digit identifying number, evaluate and possibly highlight them without me physically entering all the machine numbers into the code that would be ideal. I've attached a sample file. I have very little experience with VBA and this definately above my head. Please help.
    Attached Files Attached Files
    Last edited by bjvick; 12-06-2010 at 01:24 PM.

  2. #2
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Conditional formatting based on multiple conditions

    If your intent is to have a unique color for each machine and there are hundreds of machines, then this will be a visual mess.

    I suggest you create a downtime report based on criteria to see either specific machines are all machines. Such as using Advanced Filter to extract the relevant records into a report sheet.

    Your current structure uses a sheet for each day of the week. IMO, you are much better served by using a single sheet to contain all of the data, using a date column which is currently lacking.

    If desired, you could create a "data entry" sheet and use VBA code to feed the entries to the database sheet.

    With one sheet as the database, extracting records is easy and efficient and you have much more flexibility to do other analyses.

    See this page: Efficient Spreahsheet Design
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

  3. #3
    Registered User
    Join Date
    11-29-2010
    Location
    Milwaukee, WI
    MS-Off Ver
    Excel 2003
    Posts
    19

    Re: Conditional formatting based on multiple conditions

    Other information that varies on a daily basis will be added to the spreadsheet later so the spreadsheet must be set up this way. And I do not intend to have a unique color for every machine, just two colors yellow and red. I would like the machines which have a total weekly downtime (DTTracker tab) of between 16-25 hours to be highlighted yellow and those 25+ red. This is intended to just be a heads up so people who just glance at the DTTracker tab can see which machines have had significant downtimes.
    Last edited by bjvick; 12-01-2010 at 02:38 PM.

  4. #4
    Registered User
    Join Date
    11-29-2010
    Location
    Milwaukee, WI
    MS-Off Ver
    Excel 2003
    Posts
    19

    Re: Conditional formatting based on multiple conditions

    To simplify: I need a VBA program to run through the machine numbers in column D and find any that appear multiple times. Then I need it to add all the downtimes for the repeated machines (column F) and, if the total for any one machine is between 16 and 25, highlight all rows of that machine yellow. Machines with total dowtimes over 25 should be highlighted red. Any ideas?

  5. #5
    Registered User
    Join Date
    11-29-2010
    Location
    Milwaukee, WI
    MS-Off Ver
    Excel 2003
    Posts
    19

    Re: Conditional formatting based on multiple conditions

    I am desperately seeking help on this one. Anyone?

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

    Re: Conditional formatting based on multiple conditions

    hi, do you need that info updated all the time or it can be a button that will show result?

  7. #7
    Registered User
    Join Date
    11-29-2010
    Location
    Milwaukee, WI
    MS-Off Ver
    Excel 2003
    Posts
    19

    Re: Conditional formatting based on multiple conditions

    A simple button is good.

  8. #8
    Registered User
    Join Date
    11-29-2010
    Location
    Milwaukee, WI
    MS-Off Ver
    Excel 2003
    Posts
    19

    Re: Conditional formatting based on multiple conditions

    I was thinking the same thing arthurB, but I couldn't figure out how to get it to look at and add the same machine's dowtimes for each day without sorting the entries by machine in the DTTracker tab.

  9. #9
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Conditional formatting based on multiple conditions

    You could use a CF with following conditions

    =and(SUMIF($D$7:$D$24,D7,$F$7:$F$24)>16,SUMIF($D$7:$D$24,D7,$F$7:$F$24)<=25)
    for yellow and the 2nd condition
    =SUMIF($D$7:$D$24,D7,$F$7:$F$24)>25
    for red

    adapt the ranges to your needs or use dynamic ranges

  10. #10
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Conditional formatting based on multiple conditions

    Yes,
    and is your problem solved now?

  11. #11
    Registered User
    Join Date
    11-29-2010
    Location
    Milwaukee, WI
    MS-Off Ver
    Excel 2003
    Posts
    19

    Re: Conditional formatting based on multiple conditions

    Well I think its very very close but it seems to not be accounting for the 1st entry. At first, it would format the cell below the one it was supposed to but I changed the D7 to 6 and that seemed to do the trick. I don't understand what that number brings into the equation though. Now it seems like its doing everything perfect except it doesn't seem to be taking the first entry into consideration.

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

    Re: Conditional formatting based on multiple conditions

    please see attachment

    I assumed information is filled from left to the right (i.e. at first you fill "Machine #" and after that "Downtime" column). Input "Machine #" and "Downtime" and check result.
    Attached Files Attached Files
    Last edited by watersev; 12-03-2010 at 04:45 PM.

  13. #13
    Registered User
    Join Date
    11-29-2010
    Location
    Milwaukee, WI
    MS-Off Ver
    Excel 2003
    Posts
    19

    Re: Conditional formatting based on multiple conditions

    Watersev, I can't figure out what you did. I've attached what I have right now, I think its extremely close to working perfectly (Thank you arthurbr). The only thing it doesn't do is take the first entry into account and I can't figure out how to get it to. I've formatted the manchine number cells (Column D). Does anyone know how to get Arthur's formulas to include the first entry? Once I get the formatting figured out I'll record a macro and create a new button to do the formatting.
    Attached Files Attached Files

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

    Re: Conditional formatting based on multiple conditions

    Quote Originally Posted by bjvick View Post
    Watersev, I can't figure out what you did.
    It works with macro. Insert 1382 in cell D28 and put 20 in cell F28. It works as you described except only column "Machine ID" is coloured.

    Private Sub worksheet_change(ByVal target As Range)
    Dim x As Double, y As Long, icolor As Integer
    If target.Count > 1 Or IsEmpty(target) Or Cells(target.Row, target.Column - 2) = "" Then Exit Sub
    x = WorksheetFunction.SumIf([d:d], target.Offset(0, -2), [f:f])
    If target.Column = 6 Then
        If x >= 16 Then
            y = target.Offset(0, -2).Value
            Select Case x
                Case 16 To 25: icolor = 6
                Case Is > 25: icolor = 3
            End Select
            Application.ReplaceFormat.Interior.ColorIndex = icolor
        Range("d7:d" & target.Row).Replace what:=y, replacement:=y, ReplaceFormat:=True
        End If
    End If
    End Sub
    Last edited by watersev; 12-03-2010 at 06:43 PM.

  15. #15
    Registered User
    Join Date
    11-29-2010
    Location
    Milwaukee, WI
    MS-Off Ver
    Excel 2003
    Posts
    19

    Re: Conditional formatting based on multiple conditions

    Thanks WaterSev now I understand. It is not working after I populate the DTTracker tab. Is there a way to do the same thing with a Public macro so I can just run that after I run the macro that populates the sheet?

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

    Re: Conditional formatting based on multiple conditions

    please check attachment, run macro "Downtime"
    Attached Files Attached Files

  17. #17
    Registered User
    Join Date
    11-29-2010
    Location
    Milwaukee, WI
    MS-Off Ver
    Excel 2003
    Posts
    19

    Thumbs up Re: Conditional formatting based on multiple conditions

    Thank you very much. I won't be able to check it until Monday but I really appreciate all the help from everybody on this forum. I'm extremely glad I found this site. Thanks all.

+ 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