ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   compare oldvalue and new value of a cell (https://www.excelbanter.com/excel-programming/414607-compare-oldvalue-new-value-cell.html)

shiro[_2_]

compare oldvalue and new value of a cell
 
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



Mike H

compare oldvalue and new value of a cell
 
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


"shiro" wrote:

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





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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com