Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Posts: 7
Default how to keep conditional formatting when adding row in middle of range

I have a list of data where i am formatting the rows based on the previous row to make it easier readable (basically if the data in the row above is the same it will dim the text in the row via a formula like $a3=$a2 for a range that starts in a3). However when people are entering or changing data they will want to enter rows in the list. When you do that the conditional formatting breaks the range where the conditional formatting applies and it basically skips the rows entered (i.e. if i enter a new row 17, now row 18 will check row 16 to do the conditional formatting). I tried using named ranges when setting the conditional formatting but this does not help since excel reverts to the cell references when applying.

Does anybody have any idea how to avoid this outside only allowing adding rows via a macro so that i can re-enter the cond formatting every time a row is added?

Thanks
Mischa
  #2   Report Post  
Junior Member
 
Posts: 7
Default

Ok, i just found a solution on a MR Ozgrid thanks to Batman..

He suggested using the INDIRECT function in the conditional formatting formula, so i tried

=INDIRECT("A"&ROW())=INDIRECT("A"&ROW()-1)

tried to enter a new row in the range and surprise, surprise it worked perfectly ;-)

Mischa
  #3   Report Post  
Senior Member
 
Posts: 663
Default

Quote:
Originally Posted by Mischa_N View Post
I have a list of data where i am formatting the rows based on the previous row to make it easier readable (basically if the data in the row above is the same it will dim the text in the row via a formula like $a3=$a2 for a range that starts in a3). However when people are entering or changing data they will want to enter rows in the list. When you do that the conditional formatting breaks the range where the conditional formatting applies and it basically skips the rows entered (i.e. if i enter a new row 17, now row 18 will check row 16 to do the conditional formatting). I tried using named ranges when setting the conditional formatting but this does not help since excel reverts to the cell references when applying.

Does anybody have any idea how to avoid this outside only allowing adding rows via a macro so that i can re-enter the cond formatting every time a row is added?

Thanks
Mischa
How about something like the below formula in the conditional formatting?

=INDIRECT("A"&ROW())=INDIRECT("A"&ROW()-1)



EDIT: Gah! Beat me to it! :)

Last edited by Spencer101 : June 22nd 12 at 10:31 AM
  #4   Report Post  
Junior Member
 
Posts: 7
Default

Thanks anyway for replying Spencer..

It seems i was also celebrating too early.. This works indeed for column A but for column B i am looking at both column A and column B and although the formula works in excel (i.e. i get a true or false when needed) this formula always gives a false in conditional formatting... ??????

=AND(+INDIRECT("A"&ROW())=INDIRECT("A"&ROW()-1);+INDIRECT("B"&ROW())=INDIRECT("B"&ROW()-1))

is there a limitation in the amount of nesting you can do in conditional formatting?

Mischa
  #5   Report Post  
Junior Member
 
Posts: 7
Default

ohh and by the way, when i was just using the following the conditional formatting worked but as said before not when adding a row.. AARGHHH

=AND($a3=$a2;$b3=$b2)


  #6   Report Post  
Senior Member
 
Posts: 663
Default

Quote:
Originally Posted by Mischa_N View Post
Thanks anyway for replying Spencer..

It seems i was also celebrating too early.. This works indeed for column A but for column B i am looking at both column A and column B and although the formula works in excel (i.e. i get a true or false when needed) this formula always gives a false in conditional formatting... ??????

=AND(+INDIRECT("A"&ROW())=INDIRECT("A"&ROW()-1);+INDIRECT("B"&ROW())=INDIRECT("B"&ROW()-1))

is there a limitation in the amount of nesting you can do in conditional formatting?

Mischa
Does it work if you take the two + symbols out of the formula?
  #7   Report Post  
Junior Member
 
Posts: 7
Default

Quote:
Originally Posted by Spencer101 View Post
Does it work if you take the two + symbols out of the formula?
No.. i did not have them originally but I added them when it did not work..
  #8   Report Post  
Senior Member
 
Posts: 663
Default

Quote:
Originally Posted by Mischa_N View Post
No.. i did not have them originally but I added them when it did not work..
I've been trying this myself, also with no luck.
It's very odd because looking at the formula there is nothing wrong with it and I can see no reason why it doesn't work.

I shall keep investigating and will let you know what I find.
I will NOT let this beat me ;)
  #9   Report Post  
Junior Member
 
Posts: 7
Default

Thanks, highly appreciated, it is driving me up the wall ;-)
  #10   Report Post  
Senior Member
 
Posts: 663
Default

Quote:
Originally Posted by Mischa_N View Post
Thanks, highly appreciated, it is driving me up the wall ;-)
Try this in column B:

=AND(INDEX(A:A,ROW())=INDEX(A:A,ROW()-1),INDEX(B:B,ROW())=INDEX(B:B,ROW()-1))

I wish I could say I solved the problem for you, but alas I sought help elsewhere and got the answer far quicker than I'd have worked it out.

It's not what you know, it's who you know that knows far more than you know! ;)


  #11   Report Post  
Junior Member
 
Posts: 7
Default

Quote:
Originally Posted by Spencer101 View Post
Try this in column B:

=AND(INDEX(A:A,ROW())=INDEX(A:A,ROW()-1),INDEX(B:B,ROW())=INDEX(B:B,ROW()-1))

I wish I could say I solved the problem for you, but alas I sought help elsewhere and got the answer far quicker than I'd have worked it out.

It's not what you know, it's who you know that knows far more than you know! ;)
Great - that works perfectly. Thanks a lot for the effort!!!

In the mean time i had also figured out another way around it, namely using max 1 indirect comparison per condition and applying to more than one column:

=+NOT(INDIRECT("A"&ROW())=INDIRECT("A"&ROW()-1)) applied to column A, B and further columns
=+NOT(INDIRECT("B"&ROW())=INDIRECT("B"&ROW()-1)) aplied to column B and further columns
etc

This also works as long as you make the text is basically already in the dimmed format (it will only come in view when the autoformat is met, i.e. when it is different vs. the row above or if the columns before in the same row are different vs. their row before).

Thanks again!
Mischa
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding cells of same conditional formatting Mick Excel Worksheet Functions 0 May 7th 09 04:51 PM
Conditional Formatting: Adding more then 3 davednconfused Excel Worksheet Functions 3 July 17th 08 12:36 AM
Conditional Formatting- adding more than 3 conditions steve-o Excel Discussion (Misc queries) 6 November 7th 07 10:46 PM
Adding/Subtracting Dates and Conditional Formatting Seddie Excel Programming 1 April 10th 06 02:35 AM
Adding more than three Conditions to 'Conditional Formatting' David McRitchie Excel Discussion (Misc queries) 1 November 27th 04 06:03 PM


All times are GMT +1. The time now is 11:32 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"