+ Reply to Thread
Results 1 to 2 of 2

Help for a macro change cell colour under many conditions

  1. #1
    Registered User
    Join Date
    07-12-2005
    Posts
    2

    Help for a macro change cell colour under many conditions

    please i need help.
    If anyone can, i need a macro to colour a cell under some conditions.
    e.g.
    if (a>1 and c<1) then cell "blue"
    if (a<1 and d<1) then cell "green"
    if (a>1 and d=1) then cell "red"
    if (c>1 and e=1) then cell "yellow".

    thanks, jim

  2. #2
    Chris
    Guest

    Re: Help for a macro change cell colour under many conditions

    Think you are looking for something like this.

    Sub Collor()

    Dim Rng As Range


    With Worksheets("blad1")
    Set Rng = Range("A1:D12") ''your range where to lool

    End With
    Dim CL As Object

    Selection.Cells(1).Select
    Rng.Select
    Selection.Interior.ColorIndex = xlNone

    For Each CL In Selection.Cells
    Select Case CL.Value
    Case (a > 1 And c < 1)
    CL.Interior.ColorIndex = 3
    Case (a < 1 And d < 1)
    CL.Interior.ColorIndex = 4

    Case Else '----- color red = 3
    CL.Interior.ColorIndex = xlNone
    End Select
    Next

    '----- color white = 2
    '----- color Green = 4

    Selection.Cells(1).Select

    End Sub

    Chris


+ 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