Solved

Excel: VBA tracking. (VBA updates any changes made to worksheet.)

Posted on 2010-09-19
2
225 Views
Last Modified: 2012-05-10
Normally I use Tools-->Track Changes --->Highlight Changes.

As you know this will show a note on each cell that is changed with the following information...

1) The users name
2) Time user made the change
3) A description of the change.

I would like to create VBA that does something similar. (I don't want to use "Track Changes"...)

Therefore....What VBA would I need so that every time a user makes a change to "Sheet1" of my Excel file, on Sheet 2 column A it will log in a cell the users name/computer name, current date and if possible the first 20 characters of the change.

i.e. if the user named "Bobby" goes to "Sheet1" and updates cell C1 to "Hello on 6/7/10" then updates cell E20 to "goodbye" on 8/1/10
the following information will show on "Sheet2" in columnA

         column A
Row1: 6/7/10, Bobby, "Hello"
Row2: 8/1/10, Bobby, "goodbye"



0
Comment
Question by:ouestque
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 50

Expert Comment

by:Dave Brett
ID: 33713256
  • right click your sheet1 sheet tab
  • View - Code
  • copy and paste the code below
This code will handle multiple cell updates at once, plus it returns the logged on username - not the username entered as an Option in Excel which users can change

Note that you need to change the Sheet2 name if the second sheet is renamed

Cheers

Dave

Private Sub Worksheet_Change(ByVal Target As Range)
    Dim ws As Worksheet
    Dim c As Range
    Set ws = ThisWorkbook.Sheets("Sheet2")
    For Each c In Target
        If Not ws.[a1] = vbNullString Then
            ws.Cells(Rows.Count, "A").End(xlUp).Offset(1, 0) = Format(Now(), "d/mm/yy, ") & Environ("username") & ", " & c.Value
        Else
            ws.[a1] = Format(Now(), "d/mm/yy, ") & Environ("username") & ", " & c.Value
        End If
    Next c
End Sub

Open in new window

0
 
LVL 50

Accepted Solution

by:
Dave Brett earned 500 total points
ID: 33713266
If you wanted to capture the cell address being changed then use

Format(Now(), "d/mm/yy, ") & Environ("username") & ", " & c.Address(0, 0) & ", " & c.Value
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question