Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Source As Range)
Dim a$, nom$, i As Byte, j As Variant
If Sh.Name <> "Facture de service" Then Exit Sub
'---initialise AutreQueG39G40---
a = Source.Address(0, 0)
If a <> "G39" And a <> "G40" And a <> "G39:G40" And a <> "G39,G40" And a <> "G40,G39" _
Then AutreQueG39G40 = True
If Intersect(Source, Sh.[F4,D10,D16]) Is Nothing Then Exit Sub
Application.EnableEvents = False
'---interdit la modification du numéro de facture---
Sh.[F4] = numero
'---supprime les caractères interdits---
nom = Sh.[D10]
For i = 1 To 9
nom = Replace(nom, Mid("\/:*?""<>|", i, 1), "")
Next
Sh.[D10] = nom
'---détail du choix en D16---
Sh.[C18:G33] = "" 'RAZ
With Sheets("Feuil9") 'nom à adapter
j = Application.Match(Sh.[D16], .[A:A], 0)
If IsError(j) Then
Sh.[D16] = .[C2]
Else
For i = 1 To 16
If .Cells(i + j, 1) = "" Then Exit For
Sh.Cells(i + 17, "C") = .Cells(i + j, 1)
Sh.Cells(i + 17, "G") = .Cells(i + j, 2)
Next
End If
End With
Application.EnableEvents = True
End Sub