+ Reply to Thread
Results 1 to 6 of 6

VB code to apply Conditional formatting to a range of cells

  1. #1
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    VB code to apply Conditional formatting to a range of cells

    Hello:

    Please refer to attached file.
    I need VB Code to apply Conditional formating on selected range as follows.
    If value of cell is zero then turn to RED
    If value of cell greater then zero then turn to GREEN.

    Example:

    I select cells B5:B31 and run code should turn B6,B11,B16,B29,B31 RED and rest of the other cells
    to GREEN.

    Let me know if you have any questions.
    Thanks.

    Riz
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: VB code to apply Conditional formatting to a range of cells

    Why don't you try recording a macro of doing that?

    http://www.dummies.com/how-to/conten...n-excel-2.html

    Somebody here can tidy it up if required.

  3. #3
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB code to apply Conditional formatting to a range of cells

    Hello Stephen:

    Yes very good idea and i have done as attached.
    I would need to modify the code to select the range to apply the CF.
    Please let me know if you have any questions.
    Thanks.
    Attached Files Attached Files

  4. #4
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: VB code to apply Conditional formatting to a range of cells

    Riz - try this. If you want it to apply to any range of cells selected use as is, otherwise change as indicated on the first line.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    09-09-2013
    Location
    Kennesaw, GA, USA
    MS-Off Ver
    Excel 2013
    Posts
    42

    Re: VB code to apply Conditional formatting to a range of cells

    Can't you just highlight your cells and create two conditional format rules?
    Conditional Rules.png
    Attached Images Attached Images

  6. #6
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB code to apply Conditional formatting to a range of cells

    Hello Stephen:

    Thanks a lot, it works great.
    Riz

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Conditional formatting if in range of values: apply to column
    By marcopietro in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 09-19-2014, 02:34 PM
  2. Apply Conditional Formatting to Relative Range
    By wotaj in forum Excel General
    Replies: 1
    Last Post: 09-18-2014, 12:44 PM
  3. [SOLVED] Macro to apply Conditional Formatting to a range in every worksheet
    By Floydlevedale in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-15-2013, 01:53 AM
  4. [SOLVED] Conditional Formatting to apply to two cells
    By c.drysdale89 in forum Excel General
    Replies: 2
    Last Post: 01-25-2013, 08:26 AM
  5. [SOLVED] Conditional Formatting Apply to Range
    By daved2424 in forum Excel General
    Replies: 3
    Last Post: 09-27-2012, 08:35 AM
  6. [SOLVED] How to apply Conditional Formatting to just ONE cell and NOT its duplicates in a range?
    By otorrhea in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-25-2012, 02:31 AM
  7. Conditional Formatting won't apply to Entire Range
    By DoriBeE in forum Excel General
    Replies: 8
    Last Post: 05-11-2011, 03:55 PM

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