Solved

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

Posted on 2010-09-19
2
221 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
  • 2
2 Comments
 
LVL 50

Expert Comment

by:Dave Brett
Comment Utility
  • 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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

771 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now