+ Reply to Thread
Results 1 to 4 of 4

Formatting Cell Color and Fill with VBA

  1. #1
    Forum Contributor
    Join Date
    12-02-2010
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2013, 2016
    Posts
    100

    Formatting Cell Color and Fill with VBA

    Hello All,

    I'm writing because i'm having an issue. I would like to format two cells using VBA. It is the basic if greater than less than argument with the light green/red background and dark green/red text if true or not. But because of how I have set up my cells, I have a separate cell next to the cell containing numbers, and i want to format that as well, and since it's text, i'm having a hard time. Basically if there was a way to match the conditional formatting of another cell that is what i want to do. I feel i've done a bad job explaining this, so i'll attach the sheet i'm trying to build.

    Thank you for any help,

    DarkF1ame
    Attached Files Attached Files
    Last edited by DarkF1ame; 10-31-2011 at 01:32 PM.

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: Formatting Cell Color and Fill with VBA

    Hi Darkflame,

    You can use Conditional Formatting for this; no need for VBA.

    1. Select C43:F43 and click Conditional Formatting > New Rule...
    2. Select 'Use a formula to determine which cells to format'
    3. Beneath 'Format values where this formula is true:', type the formula

    =$C43>$F43

    4. Click the Format... button and choose your Font/Fill color.
    5. Click OK twice to return to worksheet.
    6. With C43:F43 still selected, repeat the process but for the formula use:

    =$C43<$F43

    Hope that helps!

  3. #3
    Forum Contributor
    Join Date
    12-02-2010
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2013, 2016
    Posts
    100

    Re: Formatting Cell Color and Fill with VBA

    This worked and does just what I want to. Thank you so much Paul. +1

  4. #4
    Forum Expert ConneXionLost's Avatar
    Join Date
    03-11-2009
    Location
    Victoria, Canada
    MS-Off Ver
    2010
    Posts
    2,952

    Re: Formatting Cell Color and Fill with VBA

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save
    Would you like to say thanks? Please click the: " Add Reputation" button, on the grey bar below the post.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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