+ Reply to Thread
Results 1 to 4 of 4

VB application.undo for auditing

  1. #1
    Registered User
    Join Date
    01-10-2008
    Posts
    18

    VB application.undo for auditing

    Trying to resolve how to capture the previous value of cell in a worksheet. Figured application.undo would be the best solution. How would I go about inserting this into the script and capturing the last value before it was changed?

    Please Login or Register  to view this content.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,090

    Re: VB application.undo for auditing

    You could use the Selection Change Event handler to store the value in a cell when it is selected (in a global/public variable). Then, in the Change event handler, you can refer to the previous value and record before and after values, if you wish.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    01-10-2008
    Posts
    18

    Re: VB application.undo for auditing

    Sharing an example. I like your suggestion, but some reason (can't see any noticeable differences) it is capturing the previous value after making a change.
    Attached Files Attached Files

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,090

    Re: VB application.undo for auditing

    The code seems to work OK for me.

    The difference, as far as I can see is that you have now defined PriorValue as a Public variable whereas it doesn't appear to have been defined at all in the original code.

    And then you store PriorValue but record preval. Option Explicit would avoid this type of anomaly.

    Personally, I don't like using Application.Undo and prefer to use the Selection Change event to store the current, that is, pre-change value.

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How match application undo can canceled event
    By daboho in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-18-2018, 11:24 AM
  2. [SOLVED] Application.EnableEvents and Undo
    By Brandon2013 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-25-2017, 02:58 PM
  3. [SOLVED] Application undo after a cell was moved
    By Mike911 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-30-2016, 10:16 AM
  4. Application.Undo fails in a big VBA project
    By fadosolre in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-13-2013, 10:05 AM
  5. EXCEL: Application.Undo Error
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-25-2013, 01:22 AM
  6. [SOLVED] Application.Undo failing with specific order of events
    By Bill P in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-03-2005, 03:05 PM
  7. Worksheet_Change and Application.undo
    By Mangesh Yadav in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-05-2005, 08:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1