Vba change colour cell in last row

Closed
pichon - Jan 16, 2016 at 04:49 PM
Hello,
I would like to write a VBA macro to change the background colour of a cell in the last active row in a range in sheet 2 Range (A1: A8) only if the cell in a range (A1:A5) in sheet 1 is the same as in sheet 2.
As follow:
Sheet 1
A1 A2 A3 A4 A5
1 2 3 4 5

Sheet 2
A1 A2 A3 A4 A5 A6
12 3 1 7 2 9

If value in A1 sheet 1 in range A1: A6 in sheet 2 colour red else the blanks
If value in A2 sheet 1 in range A1: A6 in sheet 2 colour orange else the blanks
If value in A1 sheet 1 in range A1: A6 in sheet 2 colour yellow else the blanks
If value in A1 sheet 1 in range A1: A6 in sheet 2 colour blue else the blanks
If value in A1 sheet 1 in range A1: A6 in sheet 2 colour green else the blanks

Example:
In our example: A3 background in sheet 2 would be red
In our example: A5 background in sheet 2 would be orange
In our example: A2 background in sheet 2 would be yellow
The other cells in sheet 2 ( A 1, A4, A6 ) would stay the same

Can anyone help?

Thanks in advance

Bruno