+ Reply to Thread
Results 1 to 5 of 5

Multiple condition, multiple range formating

Hybrid View

  1. #1
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Multiple condition, multiple range formating

    This uses a Worksheet_Change macro to watch row 6 from D6 on. It uses an array of "steps" listed in a Select Case Value test.

    All you need to do is enter the step #s in each Condition. After your original 3 samples, I added 3 more sets of random step selections to show the colors in action.
    Option Explicit
    Private Sub Worksheet_Change(ByVal Target As Range)
    'Format a range of cells based on drop selection
    If Target.Count > 1 Then Exit Sub
    If Not Intersect(Target, Range("C6:IV6")) Is Nothing Then
    Dim i As Integer, v As Integer, c As Variant
    
    i = Target.Column
    v = 14  'add row variance
    Range(Cells(15, i), Cells(45, i)).Interior.ColorIndex = xlNone
    
        Select Case Target.Value
            Case "Condition A"   'Orange
                For Each c In Array(1, 2, 7, 11, 15)   'Enter Step #s
                    Range(Cells(c + v, i), Cells(c + v, i)).Interior.ColorIndex = 40
                Next c
            Case "Condition B"   'Lite Green
                For Each c In Array(2, 5, 9, 11, 16, 21, 25, 28, 30)
                    Range(Cells(c + v, i), Cells(c + v, i)).Interior.ColorIndex = 35
                Next c
            Case "Condition C"   'Lite Blue
                For Each c In Array(1, 4, 9, 11, 16, 17, 18, 19, 22, 27, 30)
                    Range(Cells(c + v, i), Cells(c + v, i)).Interior.ColorIndex = 37
                Next c
            Case "Condition D"   'Lavender
                For Each c In Array(3, 8, 9, 10, 12, 13, 19, 20, 24, 29)
                    Range(Cells(c + v, i), Cells(c + v, i)).Interior.ColorIndex = 39
                Next c
            Case "Condition E"   'Pink
                For Each c In Array(6, 7, 8, 13, 14, 17, 19, 20, 23, 28, 31)
                    Range(Cells(c + v, i), Cells(c + v, i)).Interior.ColorIndex = 38
                Next c
            Case "Condition F"   'Grey
                For Each c In Array(1, 10, 20, 30, 31)
                    Range(Cells(c + v, i), Cells(c + v, i)).Interior.ColorIndex = 15
                Next c
            Case Else
        End Select
    End If
    End Sub
    Attached Files Attached Files
    Last edited by JBeaucaire; 04-11-2009 at 06:35 AM. Reason: Added row variance to macro
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  2. #2
    Forum Contributor
    Join Date
    10-03-2005
    Posts
    185

    Re: Multiple condition, multiple range formating

    Super Excellence! Just tried it and Works perfectly.
    Thank you very much.

    Jay

+ 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