Bonjour,
Voici un code qui ne vient pas de moi mais qui peut t'être utile.
Private Sub Worksheet_Change(ByVal Target As Range)
'Updated by Extendoffice 2017/9/12
'
' ---------------------------------------------------------
'
'
' Permet d'envoyer un mail quand une cellule xRg est modifié
'
'
' ---------------------------------------------------------------------
'
' A COPIER DANS "CLIQUE DROIT" sur l'onglet de la page puis "Visualiser le code"
'
Dim xRgSel As Range
Dim xOutApp As Object
Dim xMailItem As Object
Dim xMailBody As String
On Error Resume Next
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set xRg = Range("A2:E11") <-- A modifier selon vos envies
Set xRgSel = Intersect(Target, xRg)
ActiveWorkbook.Save
If Not xRgSel Is Nothing Then
Set xOutApp = CreateObject("Outlook.Application")
Set xMailItem = xOutApp.CreateItem(0)
xMailBody = "Cell(s) " & xRgSel.Address(False, False) & _
" in the worksheet '" & Me.Name & "' were modified on " & _
Format$(Now, "mm/dd/yyyy") & " at " & Format$(Now, "hh:mm:ss") & _
" by " & Environ$("username") & "."
With xMailItem
.To = "Email Adress"
.Subject = "Worksheet modified in " & ThisWorkbook.FullName
.Body = xMailBody
.Attachments.Add (ThisWorkbook.FullName)
.Display
End With
Set xRgSel = Nothing
Set xOutApp = Nothing
Set xMailItem = Nothing
End If
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
Modifier le xRg selon tes pré-requis.
Cette procédure envoi un mail ainsi qu'une copie du classeur via l'application Outlook dès que "xRg" est modifié.
@+