View previous cell value programmically

  • Thread starter Thread starter strataguru
  • Start date Start date
S

strataguru

Thanks for the reply.

I'm curious - how does Excel 'undo' cell values then?

Thanks
 
hi again,
ctrl+x is all i know. i never had a reason to do it
programaticly so i never looked into it. interesting
thought though.
 
Like this

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim v as Variant
Dim vOld as Variant
if target.count > 1 then exit sub
if Target.Column = 6 then
v = Target.Value
On Error goto ErrHandler
Application.EnableEvents = False
application.Undo
vOld = Target.Value
Target.Value = v
msgbox "New: " & v & vbNewline & _
"Old: " & vOld
End If
ErrHandler:
Application.EnableEvents = True
End Sub
 

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