+ Reply to Thread
Results 1 to 9 of 9

Conditional formating 7 conditions

  1. #1
    Forum Contributor ABSTRAKTUS's Avatar
    Join Date
    04-18-2010
    Location
    England
    MS-Off Ver
    Win10 Excel 2016
    Posts
    609

    Conditional formating 7 conditions

    Hi all,

    I am running XL 2003 and it gives me only 3 conditions on conditional formating. But I need 7.
    I have a code but I can't adapt it to my new project as layout is totally different. Could someone have a look where changes need to be made in a code?

    Cells to be affected are K12:AE12

    Code:

    Private Sub Worksheet_Change(ByVal Target As Range)
    If ActiveCell.Column = 4 Then
    ActiveCell.Font.ColorIndex = 1
    If ActiveCell.Value = "Black" Then ActiveCell.Font.ColorIndex = 2
    If ActiveCell.Value = "Orange" Then ActiveCell.Interior.ColorIndex = 44
    If ActiveCell.Value = "Yellow" Then ActiveCell.Interior.ColorIndex = 6
    If ActiveCell.Value = "Pink" Then ActiveCell.Interior.ColorIndex = 38
    If ActiveCell.Value = "Blue" Then ActiveCell.Interior.ColorIndex = 41
    If ActiveCell.Value = "Green" Then ActiveCell.Interior.ColorIndex = 4
    If ActiveCell.Value = "Red" Then ActiveCell.Interior.ColorIndex = 3
    If ActiveCell.Value = "Black" Then ActiveCell.Interior.ColorIndex = 1
    End If
    End Sub


    Thanks a lot!
    Last edited by ABSTRAKTUS; 04-16-2011 at 04:27 PM.

  2. #2
    Forum Expert contaminated's Avatar
    Join Date
    05-07-2009
    Location
    Baku, Azerbaijan
    MS-Off Ver
    Excel 2013
    Posts
    1,430

    Re: Conditional formating 7 conditions

    Maybe this one

    Please Login or Register  to view this content.
    Last edited by contaminated; 04-16-2011 at 03:52 PM.
    Люди, питающие благие намерения, как раз и становятся чудовищами.

    Regards, ?Born in USSR?
    Vusal M Dadashev

    Baku, Azerbaijan

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,445

    Re: Conditional formating 7 conditions

    Please note you should put CODE tags around your code.

    Please Login or Register  to view this content.

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Forum Contributor ABSTRAKTUS's Avatar
    Join Date
    04-18-2010
    Location
    England
    MS-Off Ver
    Win10 Excel 2016
    Posts
    609

    Re: Conditional formating 7 conditions

    Hi VUSAL,

    It doesn't work for some reason... Is part of code If .Column = 4 Then ActiveCell.Font.ColorIndex = 1 correct?

  5. #5
    Forum Expert contaminated's Avatar
    Join Date
    05-07-2009
    Location
    Baku, Azerbaijan
    MS-Off Ver
    Excel 2013
    Posts
    1,430

    Re: Conditional formating 7 conditions

    No... Please take a look at code once again I've just edited it.
    And can you explain, what should this part of code to do? Check whether cells column number is 4 and then color its font color?

  6. #6
    Forum Contributor ABSTRAKTUS's Avatar
    Join Date
    04-18-2010
    Location
    England
    MS-Off Ver
    Win10 Excel 2016
    Posts
    609

    Re: Conditional formating 7 conditions

    Both codes don't work... See attached.
    Attached Files Attached Files

  7. #7
    Forum Expert contaminated's Avatar
    Join Date
    05-07-2009
    Location
    Baku, Azerbaijan
    MS-Off Ver
    Excel 2013
    Posts
    1,430

    Re: Conditional formating 7 conditions

    What about this one. Seems it worked..

    Please Login or Register  to view this content.
    BTW great workbook))

    PS Real Madrid vs Barcelona has just started... I'll enjoy the game))) Hope Barsa wins))
    Last edited by contaminated; 04-16-2011 at 04:15 PM.

  8. #8
    Forum Contributor ABSTRAKTUS's Avatar
    Join Date
    04-18-2010
    Location
    England
    MS-Off Ver
    Win10 Excel 2016
    Posts
    609

    Re: Conditional formating 7 conditions

    Thanks. This worked well.

    VUSAL, you have helped me quite a few times. Can you please have a look at the other thread as it is not solved and nobody is able to help me.

    Link:

    http://www.excelforum.com/excel-gene...n-another.html

    Thanks

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,445

    Re: Conditional formating 7 conditions

    The reason that the Worksheet Change event is not working is that the cells you asked to monitor contain formulae. Changes in formulae do not trigger the Change event.

    Contaminated's solution uses the Selection Change event. The only down side is that it will reformat all those cells every time you move between cells. It may be no big deal but it is an overhead you need to be aware of.

    Regards

+ 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