ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   View previous cell value programmically (https://www.excelbanter.com/excel-programming/311213-view-previous-cell-value-programmically.html)

strataguru[_16_]

View previous cell value programmically
 

I have a vba macro that is kicked off from ThisWorkbook whe
Workbook_SheetChange event occurs.

When the user inputs or updates a value in a cell - I'd like to kno
the previous value. What object will provide me with tha
information?

Thanks!
-Robi

--
stratagur
-----------------------------------------------------------------------
strataguru's Profile: http://www.excelforum.com/member.php...nfo&userid=131
View this thread: http://www.excelforum.com/showthread.php?threadid=26291


No Name

View previous cell value programmically
 
hi,
i dont' think you can. once changed and you aint' there to
see it...it's gone. you could write code that copies all
NEW entries to a history sheet/file with control name, new
value, date, time, ect. you could then search past data to
find it.

-----Original Message-----

I have a vba macro that is kicked off from ThisWorkbook

when
Workbook_SheetChange event occurs.

When the user inputs or updates a value in a cell - I'd

like to know
the previous value. What object will provide me with that
information?

Thanks!
-Robin


--
strataguru
----------------------------------------------------------

--------------
strataguru's Profile:

http://www.excelforum.com/member.php?
action=getinfo&userid=1313
View this thread:

http://www.excelforum.com/showthread...hreadid=262910

.


Bernie Deitrick

View previous cell value programmically
 
Robin,

Use this in the change event:

Dim NewVal As Variant
Dim OldVal As Variant

If Target.Cells.Count < 1 Then Exit Sub

NewVal = Target.Value
With Application
.EnableEvents = False
.Undo
OldVal = Target.Value
.Undo
.EnableEvents = True
End With
MsgBox "The old value was " & OldVal & Chr(10) & _
"The new value is " & NewVal

HTH,
Bernie
MS Excel MVP

"strataguru" wrote in message
...

I have a vba macro that is kicked off from ThisWorkbook when
Workbook_SheetChange event occurs.

When the user inputs or updates a value in a cell - I'd like to know
the previous value. What object will provide me with that
information?

Thanks!
-Robin


--
strataguru
------------------------------------------------------------------------
strataguru's Profile:

http://www.excelforum.com/member.php...fo&userid=1313
View this thread: http://www.excelforum.com/showthread...hreadid=262910





All times are GMT +1. The time now is 07:29 PM.

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