compare oldvalue and new value of a cell

  • Thread starter Thread starter shiro
  • Start date Start date
S

shiro

Hi All,
how to write a code to compare the value of a cell
before it's being updated by user.If the new value
is different with the new value,I want the cell
background colour become different.But since
I have many sheet in my workbook,I want the code
become public and I try to keep the sheet clean
from any vba code.
Thank's

Shiro
 
Hi,


This may help. Right click your sheet tab, view code and paste this in

Private Sub Worksheet_Change(ByVal Target As Range)
If TargetVal <> Target Then
Target.Interior.ColorIndex = 3
TargetVal = vbNullString
End If

End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
TargetVal = Target
End Sub

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top