VBA - Cell Colour Change if value of cell changes

caelewis

New Member
Joined
Aug 17, 2020
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hello

I have been given this VBA to change the colour of a cell if the value of the cell is changed. It works well.

Private Sub Worksheet_Change(ByVal Target As Range)
Target.Interior.ColorIndex = 5
End Sub


My question; is there a way to change the cell colour back to the original colour, if the cell value is returned to the original value?

Thank you for your help.

Craig
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Excel does not retain a memory of the previous value, unless you were to physically store it somewhere.
So, you would need code that records the previous value every time you change a value. Because you would need to do it for each cell, you would likely need a whole other to track each value.
 
Upvote 0

Forum statistics

Threads
1,215,433
Messages
6,124,863
Members
449,195
Latest member
MoonDancer

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top