+ Reply to Thread
Results 1 to 8 of 8

Best Way to Conditionally Format Range (Multiple Columns and Rows)?

  1. #1
    Forum Contributor
    Join Date
    06-17-2010
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2010
    Posts
    228

    Best Way to Conditionally Format Range (Multiple Columns and Rows)?

    Hi Everyone,

    I'm looking to put some conditional formatting in to a macro of mine. I have a chart of data and I'd like the formatting to highlight any cell that doesn't equal column B in that row. For example:

    If C6 is greater than .5 and it doesn't equal B6, then it gets highlighted. If H22 is greater than .5 and doesn't equal B22, then it gets highlighted.

    I'm not sure how much this will change things but the amount of rows and columns are both dynamic. I already have them defined using LastRowC and LastColC. The range that the conditional formatting should go through is B3 through LastRowC and LastColC.

    Let me know if you need more info.

    Thanks!

  2. #2
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Best Way to Conditionally Format Range (Multiple Columns and Rows)?

    Is there a reason Excel's native conditional formatting won't work?
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  3. #3
    Forum Contributor
    Join Date
    06-17-2010
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2010
    Posts
    228

    Re: Best Way to Conditionally Format Range (Multiple Columns and Rows)?

    Hi again Solus -

    Do you mean just using the macro recorder and doing the conditional formatting that way? I tried it and I can't seem to find a way to make it so that each column is compared to column C. They seem to shift. If you mean, why don't I just use conditional formatting instead of a macro, that won't work because the ranges are dynamic so the conditional formatting would have to be reprogrammed every time the user runs the macro.

    Let me know if you need any other info.

    Thanks!

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Best Way to Conditionally Format Range (Multiple Columns and Rows)?

    Maybe:

    Please Login or Register  to view this content.

  5. #5
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Best Way to Conditionally Format Range (Multiple Columns and Rows)?

    You can apply conditional formatting from the Home tab to entire rows or columns.

  6. #6
    Forum Contributor
    Join Date
    06-17-2010
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2010
    Posts
    228

    Re: Best Way to Conditionally Format Range (Multiple Columns and Rows)?

    John - That doesn't seem to be making any changes...

    Solus - I understand how conditional formatting works and where to find it. That doesn't solve my question as how to code conditional formatting within vba.

  7. #7
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Best Way to Conditionally Format Range (Multiple Columns and Rows)?

    http://office.microsoft.com/en-us/ex...010370614.aspx

    Just a suggestion. Macros can bloat spreadsheets and cause problems (but then again so can formulas). If this is going to be set for a worksheet and isn't to be used repetitively then macros may not be your best choice. IMHO when ever you can use Excel native functions like conditional formatting (more information can be found through Microsoft besides the link above) then you're going to be better off.

  8. #8
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Best Way to Conditionally Format Range (Multiple Columns and Rows)?

    Quote Originally Posted by freybe06 View Post
    John - That doesn't seem to be making any changes...

    Solus - I understand how conditional formatting works and where to find it. That doesn't solve my question as how to code conditional formatting within vba.
    Can you post a sample to test on? When I ran it some made up data it seemed to work.

  9. #9
    Forum Contributor
    Join Date
    06-17-2010
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2010
    Posts
    228

    Re: Best Way to Conditionally Format Range (Multiple Columns and Rows)?

    Attached is a test book with the macro inserted.

    Attachment 277924


    Also, I know this is kinda frowned upon, but I was hoping you'd be able to take a quick look at this and tell me why its not working...I'm trying to make it so that any time the word "hello" shows up in column C of each worksheet, that row is deleted.

    Please Login or Register  to view this content.
    Thanks!

+ 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: 04-04-2013, 08:36 AM
  2. Replies: 4
    Last Post: 06-04-2012, 12:08 PM
  3. [SOLVED] Vba code to conditionally format a specific range
    By kelwood in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-29-2012, 10:14 AM
  4. Replies: 4
    Last Post: 10-27-2011, 09:31 AM
  5. Conditionally format columns
    By aias in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-28-2008, 01:10 AM

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