+ Reply to Thread
Results 1 to 2 of 2

VBA is formatting the wrong "FormatCondition"...

  1. #1
    Registered User
    Join Date
    05-13-2013
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2007
    Posts
    10

    VBA is formatting the wrong "FormatCondition"...

    First, let me explain what I'm trying to do:
    I have a spreadsheet with 7 different conditional formats. As it is basically a template, I'm trying to make this spreadsheet as easy as possible for somebody who maybe isn't great with excel to move cells around, and end up with the right conditional formatting. I don't think it should be too difficult to write a macro to clear the conditional formatting and re-apply it, so that's what I'm trying to do.

    The problem I'm having:
    The first few conditional formats the code applies are all just formatting the background color and not the font. Then when it adds conditional formats that affect the font ('Green formatting for status label for passing test sheet), it suddenly cannot seem to modify them, but instead it applies the font to the previous formats that only formatted the background color. Even when I change Selection.FormatConditions(1) to Selection.FormatConditions(2) or Selection.FormatConditions(3) (there are only 3 formats at that ponit), regardless of whether I specify 1 or 3 it still just applies the formatting to the same (wrong) format. With Selection.FormatConditions(2) it applies it to the other wrong format. I have also tried applying text formatting to the formats that currently only specify the background color, with the same results. Also, in the "'Input cell Failed formatting" block, at the ".Color = RGB(255, 255, 255)" line, I get a "Run-time error '9': Subscript out of range" error. How could it be out of range if I'm modifying the first FormatCondition?

    Details/Explainations regarding the code:
    The code below is based off of recording a macro from the actual conditional formatting that was already in the spreadsheet. "Status" is a merged cell, the named range explicitly refers to "$D$2:$F$4". "InputCells" is actually multiple dis-continuous areas. There are no cells shared between "Status" and "InputCells". The first conditional format of InputCells, which only formats the background, is executed correctly, the subsequent format of both background color and font color results in a run-time error. "SerialNo" is one of the ranges in "InputCells".

    Any help as to why this doesn't work, or suggestions on how to get it to work, would be appreciated.

    Please Login or Register  to view this content.

  2. #2
    Registered User
    Join Date
    05-13-2013
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: VBA is formatting the wrong "FormatCondition"...

    Bueller?
    ...
    Bueller?
    ...
    Bueller?
    ...
    Bueller?
    ...

    ...hmmmmm....

    Example spreadsheet attached, if it helps...

    Thanks
    Attached Files Attached Files

+ 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