+ Reply to Thread
Results 1 to 9 of 9

VBA for Conditional Format

  1. #1
    Forum Contributor Pierce Quality's Avatar
    Join Date
    07-29-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    221

    VBA for Conditional Format

    Hi All,

    I'm looking to use VBA to conditionally format a sheet and could use some help. I am attempting to add a fill color to a row (A:E) based on three conditions:

    Condition 1: Fill the row Red (Color Index 3) if Date 2 is <= Date 3

    Condition 2: Fill the row Green (Color Index 5) if Date 1 is >= Date 3

    Condition 3: Fill the row Blue (Color Index 20) if Date 1 is >= Date 3 and the text in column B for that row has an indent > 0

    If none of these condtions are met, there is no color.

    I originaly set the conditional formatting the normal way with an "And" formula, but the way a macro inputs the data into this sheet does not allow for that to work, so thats why I need to set it in VBA.

    Any help would be greatly appreciated, thanks!
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    867

    Re: VBA for Conditional Format

    there you go

    Please Login or Register  to view this content.
    .. and don't forget to have fun!
    Bogdan.

    mark SOLVED and Add Reputation if my answer pleases you

  3. #3
    Forum Contributor Pierce Quality's Avatar
    Join Date
    07-29-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    221

    Re: VBA for Conditional Format

    Quote Originally Posted by bulina2k View Post
    there you go

    Please Login or Register  to view this content.
    Hello bulina2K, thanks for the repy!
    How can I change the fill color to fill Range A:H vs the entire row?
    Thanks!

  4. #4
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    867

    Re: VBA for Conditional Format

    replace
    Please Login or Register  to view this content.
    with
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor Pierce Quality's Avatar
    Join Date
    07-29-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    221

    Re: VBA for Conditional Format

    Quote Originally Posted by VBA-Programmer View Post
    Hi
    Here is a guide for formatting ranges:
    http://www.software-solutions-online...d-ranges-/c8sj

    And here is a guide for selecting ranges:
    http://www.software-solutions-online...-of-cells/c1vh

    Let me know if you are still having trouble.



    Hire one of our VBA programmers for only 10$/hour
    Thank you very much for the resources!

    Quote Originally Posted by bulina2k View Post
    replace
    Please Login or Register  to view this content.
    with
    Please Login or Register  to view this content.
    Thank you, that works great! I just have one more question- the interior color 4 doesnt appear to be filling at all, it fills with color 20 regardless of whether the text in column B is indented or not. How do I get this to work on text that is not indented?
    Here is the code I am using-

    Please Login or Register  to view this content.
    Thanks!

  6. #6
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    867

    Re: VBA for Conditional Format

    why did you modified the code and put
    Please Login or Register  to view this content.
    where I put
    Please Login or Register  to view this content.
    there's your answer...

  7. #7
    Forum Contributor Pierce Quality's Avatar
    Join Date
    07-29-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    221

    Re: VBA for Conditional Format

    Quote Originally Posted by bulina2k View Post
    why did you modified the code and put
    Please Login or Register  to view this content.
    where I put
    Please Login or Register  to view this content.
    there's your answer...
    Sorry, I forgot about that change. When I use the 32 the row fill color will be 4 regardless if the text is indented or not. The indented text should be color 20 if it meets the date criteria.
    Thanks!

  8. #8
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    867

    Re: VBA for Conditional Format

    Can you upload your file or a part of your file so I can see what kind of indent you use? Because in your initial upload the indented text in column B starts with a space (" ") and that's exactly what this is matching :
    Please Login or Register  to view this content.


    Pls dont "Reply With Code" any more, if you answer to the last post in the Thread. Ty.

  9. #9
    Forum Contributor Pierce Quality's Avatar
    Join Date
    07-29-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    221

    Re: VBA for Conditional Format

    Quote Originally Posted by bulina2k View Post
    Can you upload your file or a part of your file so I can see what kind of indent you use? Because in your initial upload the indented text in column B starts with a space (" ") and that's exactly what this is matching :
    Pls dont "Reply With Code" any more, if you answer to the last post in the Thread. Ty.
    Thanks ty, the code I am using indents the text 2 spaces before it is copied into the master. It is copied from column F to colum B, thats why theres a different range.

    Please Login or Register  to view this content.
    The data in the example book appears to be indented two spaces, is this causing an inconsitency? It may just appear as one space because the alignment is centered.
    Thanks!
    Last edited by Pierce Quality; 02-18-2014 at 12:02 PM.

+ 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. Replies: 3
    Last Post: 05-15-2013, 12:16 AM
  2. [SOLVED] Copy Conditional Format only without over writing existing format
    By RobNorwichUK in forum Excel General
    Replies: 2
    Last Post: 01-22-2013, 12:20 PM
  3. Replies: 2
    Last Post: 09-26-2012, 04:43 AM
  4. Replies: 0
    Last Post: 05-20-2011, 02:33 PM
  5. Replies: 6
    Last Post: 08-02-2010, 04:05 PM

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