+ Reply to Thread
Results 1 to 6 of 6

VBA conditional formatting not working

  1. #1
    Registered User
    Join Date
    10-15-2007
    Location
    Charlotte, NC
    MS-Off Ver
    2003
    Posts
    50

    VBA conditional formatting not working

    Good afternoon,
    I have an excel programming book that has an example of the conditional formula I would like to use. I have modified it to fit my spreadsheet but it still doesn't work.
    Basically what should happen is: If they put in a forumla 7/8 = 88% then the cell should be red, if 8/8=100% then green else no color. I tried using the conditional formatting in the too bar but it turns all cells red.

    Did I put the code in the wrong spot? or am I missing something?

    I have attached the spreadsheet so you can see what I am doing.

    Thank you!
    Larry
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    10-15-2007
    Location
    Charlotte, NC
    MS-Off Ver
    2003
    Posts
    50

    Okay so it works but....

    I am not sure what happened but when I re-opened the spreadsheet it started working however, every time a cell is clicked it runs and it seems to be cumbersome. Is there a better place to put the code?

    Larry

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello LarryC,

    Here is the revised macro. When using event macros that change worksheet values be sure to disable further events and re-enable them when you code has finished.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  4. #4
    Registered User
    Join Date
    10-15-2007
    Location
    Charlotte, NC
    MS-Off Ver
    2003
    Posts
    50

    Talking AWESOME!! Thank you!

    Leith,
    I do have a question: Why would you have to add those lines you did when the only event was the conditional formatting I added?

    Thank you again!
    Larry

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello LarryC,

    The act of changing any cell on the worksheet triggers the WorkSheet_Change() event. When you change a cell within the event procedure, the procedure is called again, and again,and again until the stack overflows and Excel becomes unstable or crashes. This known as a "Cascade Event Failure". The addition of the 2 line of code prevent the event from retriggering while the event procedure modifies cells, and switches it back on for normal operation when done.

    Sincerely,
    Leith Ross

  6. #6
    Registered User
    Join Date
    10-15-2007
    Location
    Charlotte, NC
    MS-Off Ver
    2003
    Posts
    50

    Thank you! and Monkey wrench

    Thank you for the explaination...that helps me understand it a lot more.

    Not to throw a monkey wrench in there but, now they need to be able to change the color manually if they want to. if I change the color manually it automatically will change the cell back to the other color.

    How do I handle that?

    Larry

+ 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