+ Reply to Thread
Results 1 to 5 of 5

Coloring Cells Programatically

Hybrid View

  1. #1
    Registered User
    Join Date
    06-04-2009
    Location
    Skopje, Macedonia
    MS-Off Ver
    Excel 2003
    Posts
    5

    Coloring Cells Programatically

    Hi to all,

    In general I have 2 questions:

    1. I have the following function written VBA in excel:

    Function Ro3(r As Range) As Variant
        Dim RefString As String
        RefString = r.Address
        Ro3 = r.Worksheet.Evaluate("CHEM.MOLWEIGHT(" & RefString & ") < 300") And _
    	    r.Worksheet.Evaluate("CHEM.NUM.HBDONORS(" & RefString & ") <= 3") And _
    	    r.Worksheet.Evaluate("CHEM.NUM.HBACCEPTORS(" & RefString & ") <= 3") And _
              r.Worksheet.Evaluate("CHEMPROP.LOGP(" & RefString & ") <= 3")
    End Function
    that give TRUE/FALSE answer. Additionaly I want also the cell where is the answer to be colored, depending on the type of the answer (green for TRUE, red for FALSE). How is this possible?

    2. Is it possible to make a toolbar from function (e.g., this function)?

    Thanks in advance,
    Nikola
    Last edited by Paul; 02-02-2012 at 02:02 AM.

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

    Re: Coloring Cells Programatically

    Use conditional formatting on those cells.

    Click FORMAT > CONDITIONAL FORMATTING
    Condition1: Cell Value Is: Equal to: False
    Format...pattern...red

    Add...
    Condition2: Cell Value Is: Equal to: True
    Format...pattern...green
    _________________
    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!)

  3. #3
    Forum Contributor kraljb's Avatar
    Join Date
    05-26-2004
    Location
    Illinois
    MS-Off Ver
    2007 (recent change)
    Posts
    256

    Re: Coloring Cells Programatically

    Conditional Formatting is what you are looking to do I think.

    You can find it as follows:
    Pre-2007:
    Format: Conditional Formatting
    2007
    It's on the HOME in STYLES


    Just select the cells that going to be your answers (TRUE or FALSE) and then go to Conditional formatting and select =FALSE and make it Red highlighting and then =TRUE and green highlighting.

    Let me know if that works for you...

    Thanks,
    John

  4. #4
    Registered User
    Join Date
    06-04-2009
    Location
    Skopje, Macedonia
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Coloring Cells Programatically

    Thank you very much for your answers and solutions! I'm using Excel 2003 and I have to say that already tried this way.

    My question was is it possible to put this conditional formating into the code above?

    Regards,
    Nikola

  5. #5
    Registered User
    Join Date
    06-04-2009
    Location
    Skopje, Macedonia
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Coloring Cells Programatically

    Any solution??

+ 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