Macros Compare the last two months and remove the coloring in the first


Active Member
Feb 8, 2012
Hello, everyone,
thanks to your help, so far I have been dealing with a lot of troublesome tasks for me.
I'm here again for your help.
I have a large database table.
With other macros, I get almost to the end of this table.
I have a dilemma with which I can not fight.
The table has a range of A2:AB - by the end.
In column "D" are the dates (day, month, year), in column "G" - are the numbers or names, in column "J" - there are codes.
I'm looking for a macro that can check for the last two months (regardless of who they are) to repeat the codes in "J", according to the numbers or names in "G" against the dates in column "D".
For example, if I compare the December 2018 and January 2019 and the same number in column "G" have the same codes in column "J", make (remove) the coloration and colorless the cell (in the example given in December 2018 ) - (we are talking about all comparisons in the table).
If this condition is repeated several months back, then leave colored "G" cells without changing anything in them.
Attach a pic, if you want an example table, I will attach.
I ask for your help because I review thousands of rows and spoil my eyes from watching in every single line.
If you have questions, please ask them to explain even more.
I thank everyone for your cooperation.
picture -

Some videos you may like

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.


Active Member
Feb 8, 2012
I tried to explain it a little more understandably
The structure is as follows:
there are three important columns:
Column "D" - months,
column "G" - the number
column "J" - codes
Looking macro that if a code column "J", under the same number of column "G", it has more than two months ago to stay colored numbers, but if, for example, in January 2019 ( "D") have number in the column "G" - 12345 and in February 2019 we have the same number in the column "G" - 12345, the number in January column "G" - to be made - No fill.
If, however, this column code "J", is repeated for more than two months (February, January, December, November, etc. column "D") and the number in column "G" is the same, not to change the pink color.
And so the check is going on, with information being superimposed next month


Active Member
Feb 8, 2012
once there are no answers, there is obviously something that is not clear.
I really pray for some help.
If you have questions, please ask me.
I keep trying, but somehow I fail to count a specific number and the code for something, how many months I repeat. Somewhere I miss something, personally to me.
Thanks again to everyone.

Watch MrExcel Video

Forum statistics

Latest member

This Week's Hot Topics