I'm wanting to create a log of changes made in an excel file. I'm looking for this log to 1. let me know what cell was modified and 2. notify me by email of the modification. Not sure where to begin on this one.
Thanks,
Michael
I'm wanting to create a log of changes made in an excel file. I'm looking for this log to 1. let me know what cell was modified and 2. notify me by email of the modification. Not sure where to begin on this one.
Thanks,
Michael
Hello Michael,
Yes, it can. When do you want to be emailed? After the workbook is closed? If you get emailed every time a user makes a change, you are going to be knee deep in emails.
Sincerely,
Leith Ross
Lieth, I would want it after the workbook is closed. thxs
Hello Michael,
Place this code into a Standard VBA module. This will create your log file as a tab delimited file. There are 5 columns: (1) The date as Aug-21-2007, (2) The time in 24 hour format as hours:minutes:seconds, (3) The Worksheet's name, (4) The address of the cells that were changed, (5) The logon name of the user. Change the variable FileLoc to the directory and file name you want.
Log File Macro
To Install the Macro:![]()
Function LogCellChanges(Cell As Range) Dim FileLoc As String Dim FileNum As Integer FileNum = FreeFile FileLoc = "C:\xlChanges.log" Open FileLoc For Append As #FileNum Print #FileNum, Format(Now(), "mmm-dd-yyyy"); Tab; Format(Now(), "hh:mm:ss"); Tab; _ Cell.Parent.name; Tab; Cell.Address; Tab; Environ$("UserName") Close FileNum End Function
1. Copy the Macro code above using CTRL+C
2. Open Excel and Right Click on any Sheet Tab
3. Click on View Code in the pop up menu
4. Use ALT+I to activate the VBE Insert Menu
5. Press the letter m to insert a Standard Module
6. Paste the macro code using CTRL+V
7. Save the macro using CTRL+S
8. Close the VBE and return to excel using ALT+Q
Worksheet Macro
Place this code in each worksheet you want to log changes for.
Installing the Worksheet_Change() Event Macro![]()
Private Sub Worksheet_Change(ByVal Target As Range) LogCellChanges(Target) End Sub
1. Copy the Macro code above using CTRL+C
2. Open Excel and Right Click the Sheet Tab the macro will run on
3. Click on View Code in the pop up menu
4. PressCTRL+V to Paste the macro code
5. Press CTRL+S to Save the macro code in the workbook
6. Close the VBE and return to excel using ALT+Q
I need to work on the email portion of the macro code next.
Sincerely,
Leith Ross
Last edited by Leith Ross; 08-21-2007 at 05:32 PM.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks