+ Reply to Thread
Results 1 to 4 of 4

VBA conditional formatting -- apply to two columns

  1. #1
    Forum Contributor
    Join Date
    02-05-2014
    Location
    Bay Area
    MS-Off Ver
    Excel 2010
    Posts
    164

    VBA conditional formatting -- apply to two columns

    Hello,

    I have a conditional formatting issue, using VBA.

    My conditional formatting code works fine for one column; however, when I try to apply the conditional formatting to two columns, the code only applies to the first column listed. Additionally, I have two sets of "rules" that apply to the same column. One of the "rules" includes two columns. The other rule applies to only one column. I'm not sure if this is my issue, or whether I'm trying to apply the same code to two different columns.

    My code is below.

    Code that applies to column "M" only...
    Please Login or Register  to view this content.
    Code that applies to two columns, including column "M"...
    Please Login or Register  to view this content.
    Thanks in advance for any advice to solve my problem!

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2404
    Posts
    24,758

    Re: VBA conditional formatting -- apply to two columns

    When you say, "the code only applies to the first column listed" do you mean that after the code runs, you look at the conditional formatting that has been set up and it's wrong? Or that the conditional formatting is set up properly, but it doesn't do what you expect it to do?

    It is difficult to tell what's going on without seeing your data, and knowing what you are trying to do functionally. However, I notice that in your conditional formatting for two columns that you have relative cell references in the formula. The relative reference will be interpreted as relative to the upper left cell of the range.

    For example, your range starts in F8. The formula refers to O8, P8, and AJ8, which are the references that will be used when evaluating for F8. When this rule is evaluated for M8, the O8 in the formula will be interpreted to refer to V8, P8 will be W8, and so forth.

    Is that what you intended?

    Can you attach your file?
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Contributor
    Join Date
    02-05-2014
    Location
    Bay Area
    MS-Off Ver
    Excel 2010
    Posts
    164

    Re: VBA conditional formatting -- apply to two columns

    6StringJazzer,

    Your comment about relative references is interesting. I'm now guessing that's where my problem lies. However, I'm not sure how to correct this problem. I attached my file to this post.

    My goal is to highlight columns "F" and "M" if the conditional rule is true (called "ADVERSE_ConditionalFormat_Rule_3_4()" in my VBA code).

    Any creative thoughts?

    Thanks so much!!!
    Attached Files Attached Files

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2404
    Posts
    24,758

    Re: VBA conditional formatting -- apply to two columns

    I understand that you to highlight F and M if the rule is true, but I have no way to verify whether that rule expresses what you want to happen. Imagine someone giving you an equation

    y = x^2 + 3

    and then they ask, "Will that give me the parabola I need?"

    Can you give me the English version of what you need? For example, does highlighting column M depend on whether the cell in column V is n/a or >2, or is it really supposed to be column O, or is it supposed to be another column altogether?

+ 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. [SOLVED] conditional formatting apply to 2 columns
    By johnandrews in forum Excel General
    Replies: 3
    Last Post: 12-31-2013, 08:54 AM
  2. [SOLVED] Apply Conditional Formatting to Multiple Columns
    By vinceancona in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-31-2013, 04:49 PM
  3. Macro to apply colour conditional formatting to four columns
    By mayfaring in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-24-2013, 08:16 PM
  4. Using a macro to apply conditional formatting to multiple columns
    By test-card girl in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-29-2007, 05:43 PM
  5. EXCEL 2003: Apply Conditional Formatting to COLUMNS
    By HWDFWXCLGuru in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-01-2005, 12:06 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