1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| Private Sub CommandButton2_Click()
Dim i As Integer, j As Integer
Dim rng As Range
Dim bool As Boolean
With Worksheets("Base")
If MsgBox("Confirmez-vous linsertion de cette nouvelle campagne ?", vbYesNo, "Demande de confirmation dajout") = vbYes Then
Set rng = .Columns(16).Find("*", , , , , xlPrevious)
bool = True
For i = 1 To rng.Row
If .Range("P1").Offset(i, 0) = Me.TextBox1 Then
If Me.CheckBox1 Then
For j = 1 To rng.Row - 1
.Range("Q1").Offset(j, 0) = 0
Next j
.Range("P1").Offset(i, 1) = 1
bool = False
Exit For
Else
MsgBox "Campagne déjà insérée"
End If
End If
Next i
If bool Then
rng.Offset(1, 0) = Me.TextBox1
If Me.CheckBox1 Then
rng.Offset(1, 1) = 1
For j = 1 To rng.Row - 1
.Range("Q1").Offset(j, 0) = 0
Next j
Else
rng.Offset(1, 1) = 0
End If
End If
End If
End With
Unload Me
End Sub |
Partager