Modification de code

adr99

XLDnaute Nouveau
Bonjour à tous,

Je souhaite modifier ce code : If Not Intersect(Target, [J2]) Is Nothing Then
par un test d'un clique sur un bouton d'un userform est-ce possible je vous me le reste du code :

Private Sub Worksheet_Change(ByVal Target As Range)
Dim i As Integer, Lig As Long, Col As Integer
Dim S As String, Cel As Range
If Target.Count > 1 Then Exit Sub

If Not Intersect(Target, [J2]) Is Nothing Then
Application.EnableEvents = False
[D3:D17].ClearContents
[AC3:AC17].ClearContents
S = Target.Text
With Sheets("test2")
For i = 11 To 19
If .Cells(2, i) = S Then
Set Cel = .Cells(2, i)
Exit For
End If
Next i
If i > 20 Then Exit Sub

Lig = 3: Col = Cel.Column - 2
For i = 1 To 37
If Cel.Offset(i, 0) = 1 Then
Sheets("test").Cells(Lig, "D") = Cel.Offset(i, -Col).Value
Lig = Lig + 1
End If
Next i
Sheets("test").Cells((Lig), "AC") = "$$ fin $$"
End With
Application.EnableEvents = True
End If
end sub