Results 1 to 8 of 8

VBA code for audit trail issue

Threaded View

  1. #1
    Registered User
    Join Date
    06-05-2015
    Location
    UK
    MS-Off Ver
    2013
    Posts
    35

    VBA code for audit trail issue

    Hi,

    Not sure if this will be possible - I have a workbook in which vba is used to record changes made on one sheet onto another sheet called 'log'.

    The code works fine when people make changes in cells one at a time but if they paste in data to more than one cell at once I get a run time error '13'.

    So the code I am using on the sheet where the changes are is:


    Dim PreviousValue
    
    Private Sub Worksheet_Change(ByVal Target As Range)
        If Target.Value <> PreviousValue Then
            Sheets("log").Cells(65000, 1).End(xlUp).Offset(1, 0).Value = _
                Application.UserName & " changed cell " & Target.Address _
                & " from " & PreviousValue & " to " & Target.Value
                         
        End If
    End Sub
    
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
        PreviousValue = Target.Value
    End Sub
    The code on the log sheet is:

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Column = 1 Then
    Cells(Target.Row, 4).Value = Now
    End If
    End Sub

    Any ideas how I can enable the changes to be logged if more than 1 cell is changed at once? Thanks in advance for anyone taking the time to look at this.
    Last edited by TheGrinch1; 06-05-2015 at 09:01 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Audit Trail
    By jenziepie in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-01-2013, 01:56 PM
  2. Doing an audit trail on multiple sheets
    By Nett in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-05-2013, 08:18 PM
  3. Excel Audit Trail?
    By jvest0648 in forum Excel General
    Replies: 1
    Last Post: 12-17-2011, 02:57 PM
  4. Track Changes - Audit Trail
    By ChemistB in forum Excel General
    Replies: 2
    Last Post: 10-27-2006, 02:16 PM
  5. 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