+ Reply to Thread
Results 1 to 3 of 3

Colour results cell based on cell colour of Min( )

Hybrid View

EricofPendom Colour results cell based on... 08-09-2012, 12:19 PM
wakeupcall Re: Colour results cell based... 08-09-2012, 01:37 PM
EricofPendom Re: Colour results cell based... 08-10-2012, 03:33 AM
  1. #1
    Registered User
    Join Date
    04-15-2010
    Location
    Lancashire, England
    MS-Off Ver
    Office 2007 SP3
    Posts
    21

    Colour results cell based on cell colour of Min( )

    Hi Folks,

    I have 5 companies that supply a figure for an item and each of the companies has a specific colour for their column of data in the sheet. I have a column to the right of these that returns the Min( ) of these five figures and I would like to automatically colour the cell the same as the company colour using VBA. I can't figure out how to capture the range from the min( ) statement and then get the colour of the cell in question.

    I have attached a sample showing the result I require.

    Any help would be most appreciated.

    Thanks in advance

    Eric...
    Attached Files Attached Files

  2. #2
    Forum Contributor wakeupcall's Avatar
    Join Date
    02-29-2012
    Location
    Sofia, Bulgaria
    MS-Off Ver
    Excel 2010
    Posts
    155

    Re: Colour results cell based on cell colour of Min( )

    Hi,

    Have a look at this

    
    Sub Colour_Value()
    
    Dim Cell As Range
    
    With ActiveSheet
    
    Range("F2").Formula = WorksheetFunction.Min(Range("A2:E2"))
    Range("F2:F9").FillDown
    
    For Each Cell In Range("F2:F9")
    
    If Cell.Value = Cells((Cell.Row), 1) Then
    Cell.Select
        With Selection.Interior
            .Pattern = xlSolid
            .PatternColorIndex = xlAutomatic
            .ThemeColor = xlThemeColorLight2
            .TintAndShade = 0.799981688894314
            .PatternTintAndShade = 0
        End With
    End If
    
    If Cell.Value = Cells((Cell.Row), 2) Then
    Cell.Select
       With Selection.Interior
            .Pattern = xlSolid
            .PatternColorIndex = xlAutomatic
            .ThemeColor = xlThemeColorAccent2
            .TintAndShade = 0.799981688894314
            .PatternTintAndShade = 0
        End With
    End If
    If Cell.Value = Cells((Cell.Row), 3) Then
    Cell.Select
        With Selection.Interior
            .Pattern = xlSolid
            .PatternColorIndex = xlAutomatic
            .ThemeColor = xlThemeColorAccent3
            .TintAndShade = 0.799981688894314
            .PatternTintAndShade = 0
        End With
    End If
    
    If Cell.Value = Cells((Cell.Row), 4) = True Then
    Cell.Select
        With Selection.Interior
            .Pattern = xlSolid
            .PatternColorIndex = xlAutomatic
            .ThemeColor = xlThemeColorDark2
            .TintAndShade = -9.99786370433668E-02
            .PatternTintAndShade = 0
        End With
    End If
    
    If Cell.Value = Cells((Cell.Row), 5) = True Then
    Cell.Select
        With Selection.Interior
            .Pattern = xlSolid
            .PatternColorIndex = xlAutomatic
            .ThemeColor = xlThemeColorAccent5
            .TintAndShade = 0.799981688894314
            .PatternTintAndShade = 0
        End With
    End If
    
    Next Cell
    
    End With
    End Sub
    If your the length of the columns change with every run, you should replace this
     ("F2:F9")
    with this

    ("F2:F" & .UsedRange.Rows.Count)

  3. #3
    Registered User
    Join Date
    04-15-2010
    Location
    Lancashire, England
    MS-Off Ver
    Office 2007 SP3
    Posts
    21

    Re: Colour results cell based on cell colour of Min( )

    Thanks Wakeupcall that works great.

+ 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