+ Reply to Thread
Results 1 to 8 of 8

"If" and Syntax to change font and fill (interior) color based on cell value

  1. #1
    Registered User
    Join Date
    01-12-2012
    Location
    Rockland, WI
    MS-Off Ver
    Excel 2016
    Posts
    56

    "If" and Syntax to change font and fill (interior) color based on cell value

    How do I structure my If statement to change the font and fill color if the cell value is between -500 and 500? I have the following code which works with debug.print where I would like to change the font and fill colors.

    Please Login or Register  to view this content.
    Last edited by jdfjab; 02-17-2012 at 12:24 PM.

  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: "If" and Syntax to change font and fill (interior) color based on cell value

    Why are you using VBA? Conditional formatting on that range will allow you to set that up quickly and it will run in realtime automatically.
    _________________
    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
    Registered User
    Join Date
    01-12-2012
    Location
    Rockland, WI
    MS-Off Ver
    Excel 2016
    Posts
    56

    Re: "If" and Syntax to change font and fill (interior) color based on cell value

    It's part of a longer sub that clears and rebuilds the sheet "lastmaintenance". The conditional formating rules "increase" in number with new ranges every time the sub is run.

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

    Re: "If" and Syntax to change font and fill (interior) color based on cell value

    Turn on the macro recorder and let it record you applying CF to that column based on the current number of rows of data. Post the resulting code here and we can help you tweak that into a more dynamic version that will apply to the existing range of data each time.

  5. #5
    Registered User
    Join Date
    01-12-2012
    Location
    Rockland, WI
    MS-Off Ver
    Excel 2016
    Posts
    56

    Re: "If" and Syntax to change font and fill (interior) color based on cell value

    Here is the Macro recorded code, except it must exclude value 0 or "" also

    Please Login or Register  to view this content.

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

    Re: "If" and Syntax to change font and fill (interior) color based on cell value

    Record a macro of you applying ALL of the conditional formatting rules needed to get the results you need. Once you have all that figured out and working, show us THAT code.

  7. #7
    Registered User
    Join Date
    01-12-2012
    Location
    Rockland, WI
    MS-Off Ver
    Excel 2016
    Posts
    56

    Re: "If" and Syntax to change font and fill (interior) color based on cell value

    Thanks.
    Here is what I ended up with:

    Please Login or Register  to view this content.

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

    Re: "If" and Syntax to change font and fill (interior) color based on cell value

    Can you provide a link to the other forum posts where that was worked out? 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