+ Reply to Thread
Results 1 to 8 of 8

Audit trail macro to handle insertion or row or column and the cut and paste functionality

  1. #1
    Registered User
    Join Date
    11-08-2016
    Location
    Greenville, South Carolina
    MS-Off Ver
    2007 & 2013
    Posts
    3

    Audit trail macro to handle insertion or row or column and the cut and paste functionality

    So the short and skinny of it is that I have pieced this macro together and in no way claiming to be even a novice at Excel and vba. Anyways, I am trying to get this audit trail macro to be able to handle two conditions.
    1st is the insertion of a row or a column. The macro faults out with the insertion of a row or column, and I thought I had it licked at one point but it would still crash out even with the log actually logging the inserted row. So I decided to strip it backing to working conditions. Basically, what is happening is that the code is breaking upon not having a previous cell value, but I cannot for the life of me figure out a way to appropriately handle it. Also, the macro handles each cell change, so I would rather the macro stop at the first conditional cell error and just log in the audit trail section row or cell was inserted.
    2nd is correcting the cut and paste functionality that seems to be busted. Only the first part (the cut) is logged and then the paste function is not working. I am thinking this is mainly due to the application.undo feature but wouldn't bet my life on it. It seems to still work with Copy and paste.

    I am trying to create either solution without using worksheet_selectionchange sub if at all possible. PW is "password" and any help is appreciated.
    Attached Files Attached Files
    Last edited by zephyriswing; 11-15-2016 at 10:31 AM.

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Audit trail macro to handle insertion or row or column and the cut and paste functiona

    Ignore ....

  3. #3
    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,372

    Re: Audit trail macro to handle insertion or row or column and the cut and paste functiona

    I think the Undo destroys the Target range. So, maybe try it like this:

    Please Login or Register  to view this content.
    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


  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,372

    Re: Audit trail macro to handle insertion or row or column and the cut and paste functiona

    The code does now appear to work. However, if you insert a row or a column, it has a lot of cells to check ... particularly if you insert a column ... and takes a while to execute. Not sure how bad it would get if you were to insert several columns. You might want to limit it by taking the intersection of the Target Range and the Used Range.

  5. #5
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Audit trail macro to handle insertion or row or column and the cut and paste functiona

    Here's and alternative method. Instead of using Application.Undo, it uses a duplicate data sheet called Data Entry Mirror. It compares the changes on the Data Entry sheet to it's mirror sheet, logs the differences, and updates the mirror sheet.

    First make a copy of the Data Entry sheet and name it Data Entry Mirror. You could hide this sheet if you wanted.

    It also logs if a rows or columns have been inserted or deleted.

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  6. #6
    Registered User
    Join Date
    11-08-2016
    Location
    Greenville, South Carolina
    MS-Off Ver
    2007 & 2013
    Posts
    3

    Re: Audit trail macro to handle insertion or row or column and the cut and paste functiona

    Thanks for your input, it was really helpful!

  7. #7
    Registered User
    Join Date
    11-08-2016
    Location
    Greenville, South Carolina
    MS-Off Ver
    2007 & 2013
    Posts
    3

    Re: Audit trail macro to handle insertion or row or column and the cut and paste functiona

    Wow, I never thought about solving it that way. AlphaFrog That solution's pretty awesome. It executes really quickly too. I appreciate the help and am really grateful!

  8. #8
    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,372

    Re: Audit trail macro to handle insertion or row or column and the cut and paste functiona

    You're welcome. Thanks for the rep.

+ 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. Turn Audit Trail on and off
    By kati.coy in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-22-2016, 11:34 AM
  2. Audit Trail
    By Moggzzz in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-29-2016, 06:48 AM
  3. Build audit trail for accumulator macro
    By sipa in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-07-2015, 07:19 AM
  4. Audit Trail
    By jenziepie in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-01-2013, 01:56 PM
  5. Excel Audit Trail?
    By jvest0648 in forum Excel General
    Replies: 1
    Last Post: 12-17-2011, 02:57 PM
  6. Track Changes - Audit Trail
    By ChemistB in forum Excel General
    Replies: 2
    Last Post: 10-27-2006, 02:16 PM
  7. Audit Trail
    By Pendelfin in forum Excel General
    Replies: 1
    Last Post: 01-23-2006, 11:10 AM

Tags for this Thread

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