• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Excel Audit Trail VBA

riveraor

New Member
Hello,


I have this code that records all changes made in a workbook (audit trail). The thing is that it records everything even if the workbook is not saved. How can I change this in order to do the recording only when it is save.


'Sub AuditTrail(ByVal Sh As Object, ByVal Target As Range)


'Dim strFileName As String

'strFileName = "c:test.txt"


' Open strFileName For Append As #1


' If Target.Count > 1 Then

Print #1, ThisWorkbook.Name & vbTab & Sh.Name & vbTab & Target.Address & vbTab & Environ("username") & vbTab & Date & vbTab & Time & vbTab & "Multiple cells changed"

Else


' Print #1, ThisWorkbook.Name & vbTab & Sh.Name & vbTab & Target.Address & vbTab & Environ("username") & vbTab & Date & vbTab & Time & vbTab & Target.Value

' End If


' Close #1

'End Sub
 
Hi, riveraor!


First of all welcome to Chandoo's website Excel forums. Thank you for your joining us and glad to have you here.


As a starting point I'd recommend you to read the green sticky topics at this forums main page. There you'll find general guidelines about how this site and community operates (introducing yourself, posting files, netiquette rules, and so on).


Among them you're prompted to perform searches within this site before posting, because maybe your question had been answered yet.


Feel free to play with different keywords so as to be led thru a wide variety of articles and posts, and if you don't find anything that solves your problem or guides you towards a solution, you'll always be welcome back here. Tell us what you've done, consider uploading a sample file as recommended, and somebody surely will read your post and help you.


And about your question...


Where is that procedure AuditTrail called from? That should be the starting point to answer your question, I guess.


Regards!
 
Back
Top