
getting previous cell values in excel sheets
Hi niraj,
Y'd be looking for somehting like:
Dim OldVal As Variant
'validate change in cell, in this case, it
'restores original value of target if users input 999
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target = "999" Then Target = OldVal
End Sub
'store value of new selection
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
OldVal = Target
End Sub
Krgrds,
Perry
Quote:
> hi all,
> when we enter a value in a cell, the worksheet_change
> event is invoked in it's vba code.
> if we want to validate the new value entered and restore
> it back to the original value, if the new value is
> invalid how do we do it?
> thanks,
> niraj.