+ Reply to Thread
Results 1 to 1 of 1

Conditional Formatting using VBA for multiple conditions

  1. #1
    Registered User
    Join Date
    01-18-2011
    Location
    Somerset
    MS-Off Ver
    Excel 2010
    Posts
    28

    Conditional Formatting using VBA for multiple conditions

    Within Excel 2003, I have created a table of 7 columns and 10 rows. Column 7 represents the sum of the first 6 colomns at each row level. I need to apply a background colour in column 7 (H1:H10) which changes dependant on the summed value.

    Please see the attched sheet.

    To achieve this I have followed this example ….

    Private Sub Worksheet_Change(ByVal Target As Range)

    Dim icolor As Integer

    If Not Intersect(Target, Range("G3:G13")) is Nothing Then

    Select Case Target

    Case 0 To 9

    icolor = 4

    Case 10 To 19

    icolor = 8

    Case 20 To 29

    icolor = 26

    Case 30 To 49

    icolor = 53

    Case 21 To 25

    icolor = 15

    Case 50 To 999

    icolor = 3

    Case Else

    'Whatever

    End Select

    Target.Interior.ColorIndex = icolor

    End If


    End Sub



    However, this only works if the values of columns A to F have already been populated prior to creating the rule.

    The ‘Pre Filled Data’ tab show the example of the A to F columns being completed prior to the creation of the rule. If I then change the values in columns A to D, the column E cell recalculates as per the formula but retains its original cell colour.

    I also need this to work on a second table within the worksheet, using the same colour conditions.

    Do I simply make the following amendment:

    If Not Intersect(Target, Range("G3:G13", "O3:O13")) is Nothing Then

    Thanks in advance for your help.
    Attached Files Attached Files
    Last edited by stephboucher; 01-18-2011 at 04:20 PM.

+ 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