If a particular person changes a workbook email me

gruple

New Member
Joined
Dec 5, 2005
Messages
8
I need to know if a particular employee tries to make changes to a workbook that I don't want him to. I cannot limit him from accessing it because of our IT policy. Is there a way to email me if or when he makes a change? Or is there a way to highlight it or something? Thanks for the help.
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
There are two parts of this code. The first must be pasted in a normal module and is a function that gets the user id of the person logged onto the network:

Code:
Option Explicit

'******************** Code Start **************************
' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
    "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
    strUserName = String$(254, 0)
    lngLen = 255
    lngX = apiGetUserName(strUserName, lngLen)
    If (lngX > 0) Then
        fOSUserName = Left$(strUserName, lngLen - 1)
    Else
        fOSUserName = vbNullString
    End If
End Function

The second part goes into the sheetChange event of the workbook. Everytime a sheet is changed it will send a copy of the workbook to the recipient. Note you may end up with a full inbox if the user makes a lot of changes. (you could change this to the workbook open event and then you receive it only whe the specified user open the workbook). Obviously you can put something else in the IF clause to reflect what you want to do:

Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
     If fOSUserName() = "User to Check" Then
        ThisWorkbook.SendMail Recipients:="John Smith" 'replace with your e-mail name

     End If
     
     
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,253
Members
448,556
Latest member
peterhess2002

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top