Bonjour à toute et a tous,
J'ai script VBA trés fonctionnelle mais seulement quand j'intervient manuellement.
Est il possible de le rendre exécutable automatiquement aprés chaque mise à jour ?
Ci dessous le script en entier :
Option Explicit
Public x$, cc, xx$, xxx$
Sub envoyer()
Dim i&, a&, aa, bb, y&, n&, fin&
Feuil1.Cells.Copy Feuil3.Cells
Feuil3.Range("A3:Y" & Feuil3.Range("A" & Rows.Count).End(3).Row).ClearContents
With Feuil2
aa = .Range("A2:B" & .Range("A" & Rows.Count).End(xlUp).Row)
End With
With Feuil1
bb = .Range("A3:Y" & .Range("A" & Rows.Count).End(xlUp).Row)
End With
For i = 1 To UBound(aa)
ReDim cc(1 To UBound(bb), 1 To UBound(bb, 2)): y = 1
For a = 1 To UBound(bb)
If aa(i, 1) = bb(a, 1) Then
For n = 1 To UBound(bb, 2)
cc(y, n) = bb(a, n)
Next n
y = y + 1
End If
Next a
If y = 1 Then
GoTo 1
Else
Feuil3.Range("A3").Resize(UBound(cc), UBound(cc, 2)) = cc
Feuil3.Range("A" & Feuil3.Range("A" & Rows.Count).End(3).Row + 1) = Feuil2.Range("F2")
Feuil3.Select
x = aa(i, 2)
Call EnvoiPlage
With Feuil3
fin = .Range("A" & Rows.Count).End(3).Row
If fin < 2 Then fin = 2
.Range("A3:Y" & fin).ClearContents
End With
End If
1 Next i
Feuil3.Cells.Clear
Feuil2.Select
End Sub
Sub EnvoiPlage()
ActiveSheet.Range("A1:Y" & ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row).Select
With Feuil2
xx = .Range("E2")
xxx = .Range("H2")
End With
ActiveWorkbook.EnvelopeVisible = True
With ActiveSheet.MailEnvelope
.Introduction = ""
.Item.To = x
.Item.cc = xx
.Item.Subject = xxx
.Item.Send
End With
End Sub