+ Reply to Thread
Results 1 to 7 of 7

Inserting/Deleting Rows Causes Issues with Conditional Formatting Macro

  1. #1
    Registered User
    Join Date
    09-29-2014
    Location
    Dallas, TX
    MS-Off Ver
    2010
    Posts
    45

    Inserting/Deleting Rows Causes Issues with Conditional Formatting Macro

    I have a macro that does a bunch of conditional formatting {i.e. changes the fort color based on date (items older than today are red, today plus the next 7 days are purple) and shades other items mint green if column G has 1 or 3 or H has a 1 - this probably TMI)}. See below. There's also a sample attached.

    The macro works fine. It does exactly what it should. Here's the problem. If I insert or deleted a row, the conditional formatting rule breaks/splits. The best way to describe it is.....the formatting is stuck in/with the cell despite the fact that the data (which is what caused the cell's font/fill to change in the 1st place, but that's the point of a conditional) has been shifted. Any advice on how to fix it?

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by lashellr; 11-05-2014 at 11:29 AM.

  2. #2
    Valued Forum Contributor natefarm's Avatar
    Join Date
    04-22-2010
    Location
    Wichita, Kansas
    MS-Off Ver
    2016
    Posts
    1,020

    Re: Inserting/Deleting Rows Causes Issues with Conditional Formatting Macro

    I'm not seeing the problem. I ran the code to set the conditionals, then inserted and deleted rows, and the conditionals continue to work just fine on the new rows as well as the originals.
    Acts 4:12
    Salvation is found in no one else, for there is no other name under heaven given to mankind by which we must be saved.

  3. #3
    Registered User
    Join Date
    09-29-2014
    Location
    Dallas, TX
    MS-Off Ver
    2010
    Posts
    45

    Re: Inserting/Deleting Rows Causes Issues with Conditional Formatting Macro

    Pic.jpg

    Here's what it looks like when I insert 10 rows.

  4. #4
    Registered User
    Join Date
    09-29-2014
    Location
    Dallas, TX
    MS-Off Ver
    2010
    Posts
    45

    Re: Inserting/Deleting Rows Causes Issues with Conditional Formatting Macro

    Revised HelpMe12.xlsm

    Here's a sample in excel form. In the end, I am inserting several rows of data from a separate workbook.

  5. #5
    Valued Forum Contributor natefarm's Avatar
    Join Date
    04-22-2010
    Location
    Wichita, Kansas
    MS-Off Ver
    2016
    Posts
    1,020

    Re: Inserting/Deleting Rows Causes Issues with Conditional Formatting Macro

    It appears that the problem occurs when you insert rows before row 1. Hopefully I can explain why, though I may not have the correct understanding myself, but I think it's close. When your code creates the conditions, it does so using relative row #1 ($G1, $I1, $H1). If you look at the conditional formatting in a cell in any row, it will still have 1 in the formula, which apparently points to itself (the cell's row) rather than actual row 1. If you insert rows after row 1, the conditions in those and subsequent rows still point to themselves. However, if you insert, say 3 rows before row 1, all the subsequent rows' conditional format formulas get bumped up by 3 rows, so they will then say $G4, $I4, and$H4. I don't totally understand it, but that's what is happening. You can address it by either not inserting rows before row 1, or by just rerunning your code after your insertion.

  6. #6
    Registered User
    Join Date
    09-29-2014
    Location
    Dallas, TX
    MS-Off Ver
    2010
    Posts
    45

    Re: Inserting/Deleting Rows Causes Issues with Conditional Formatting Macro

    That is exactly what is happening. I just thought there was a way to revise the code to keep if from happening. I can't run the macro after, as it is actually part of a larger macro that must run together in a certain order. I really need to be able to insert/delete. Maybe, I can try to find a work around. Or, someone else has had and resolved the same issue.

  7. #7
    Valued Forum Contributor natefarm's Avatar
    Join Date
    04-22-2010
    Location
    Wichita, Kansas
    MS-Off Ver
    2016
    Posts
    1,020

    Re: Inserting/Deleting Rows Causes Issues with Conditional Formatting Macro

    Just put this code in a subroutine called by the other macro where needed, and you can run it when needed.

+ 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. Conditional Formatting Behavior When Deleting Rows
    By DanBlum in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-08-2014, 01:08 AM
  2. Conditional formatting splits when inserting new rows
    By physicsgal in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 08-16-2013, 09:58 AM
  3. Deleting rows without conditional formatting
    By ShawnaC in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-11-2013, 02:38 PM
  4. Disable macro when inserting/deleting rows
    By aznprod517 in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 10-29-2009, 09:40 AM
  5. [SOLVED] Conditional Formatting Reference / Inserting Rows
    By Werner Rohrmoser in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-09-2005, 10:05 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