+ Reply to Thread
Results 1 to 4 of 4

VBA Conditonal Formatting

  1. #1
    Registered User
    Join Date
    06-18-2009
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    6

    Thumbs up VBA Conditonal Formatting

    Hi All,

    I'm trying to shade a selected range in this way:


    if it's "R", color=red

    if it's "O", color=orange

    if it's "P", color=purple

    if it contains "Y", color=yellow

    if it contains "G", color=green

    for example, if a cell is "G.1/31/2009", I would like it to be shaded in green.

    Here is a code I'm trying to use, but I am new to VBA and has no idea how to search "Y" or "G" and shade them. Could anyone help me on this? Many thanks in advance.


    Please Login or Register  to view this content.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: VBA Conditonal Formatting

    Where have you put the code?
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    06-18-2009
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: VBA Conditonal Formatting

    Quote Originally Posted by royUK View Post
    Where have you put the code?
    in VB?..

    I just right clicked the tab and clicked "view code" then copy the code. Is this the right way?

  4. #4
    Registered User
    Join Date
    06-18-2009
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: VBA Conditonal Formatting

    I just figured out I can certainly search "G" and "Y" by using "Format"-"Conditional Formatting" like this:

    =ISNUMBER(SEARCH("G",AA4)) then make format color=green
    =ISNUMBER(SEARCH("Y",AA4)) then make format color=yellow

    But I still need to do the rest three colors by VBA. I'm wondering if there is anyway I can do ALL conditions in VBA? Thanks.

+ 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