Consulting

Results 1 to 8 of 8

Thread: Solved: write log of changes in workbook

  1. #1

    Solved: write log of changes in workbook

    Hi all,
    i try figured out, if its possible to made some code, which will always after changing and saving wb, write log in one file (at the START of one log.txt - the newest will be in 1. line).
    I mean, if it is possible to write in this log:
    - date, time of change
    - name of sheet, where was change
    - the last 3 position of changed areas (A1, A4: D5, C400)
    - user whos did the change

    resluts will be something like this:
    - 1/6/09 - sheet1 - (E5, W230, A5: w30) - johnyQ
    - 1/6/09 - sheet2 - (E5, W230, A5: w30) - suziQ
    - 2/6/09 - sheet1 - (E10, W133, D35) - peter
    ...

    thx

  2. #2
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  3. #3
    VBAX Mentor MaximS's Avatar
    Joined
    Sep 2008
    Location
    Stoke-On-Trent
    Posts
    360
    Location
    or try:

  4. #4
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    I demonstrated 2 methods in this thread: save to text file and save to and MDB table. http://vbaexpress.com/forum/showthread.php?t=22620

    I think you would be better off using a log file as a database file. You could always use SQL to sort it and get all of the modified cells rather than just the last 3.

  5. #5
    thank you to all
    i will try it your codes or links

  6. #6
    HI ,
    why pls. this code return wrong reference?
    Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
          LogInformation ActiveSheet.Name & Selection.Address & " Changed: " & _
                        " " & Format(Now, "dd" & "." & "mm" & "." & "yy" & " " & "hh:mm:ss") & " " & Application.UserName
    End Sub

    f.e. if i write something to I20 it write to log I21 ?

  7. #7
    now i figured out, that it write reference, where ended cursor. If i somehting write to cell and use enter it write row+1, if i use tab it write column +1

    how can fix it?
    thx
    and how can i
    - add free row to logfile.txt after save ?
    - add "tab" separator between data in one row?

    thx a lot

  8. #8
    i´ve got it
    only fyi - for other readers:

    - tab - is in VBA
    HTML Code:
    vbTAB


    - free line i write like this - only as other command
    HTML Code:
    LogInformation " "
    f.e. whole line for writting LOG for me is:

    Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
          LogInformation Format(Now, "dd" & "." & "mm" & "." & "yy" & " " & "hh:mm:ss") & ";" _
          & vbTab & Application.UserName & ";" & vbTab & vbTab & "Changed" & ";" & vbTab & _
          Selection.Address & ";" & vbTab & vbTab & ActiveSheet.Name
    End Sub
    maybe it helps

Posting Permissions

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