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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
| Public co1 As Integer: Public li1 As Integer
Dim fourn As String: Dim a2 As Boolean
Private Sub CommandButton1_Click()
' Bouton Valider choix
If a1 = False Then
Worksheets("Feuil1").Activate
UserForm1.Hide
Application.ScreenUpdating = False
'
fourn = ComboBox1.Value
li1 = ActiveCell.Row
Cells(li1, 1).Value = fourn
Cells(li1 + 1, 1).Activate
End If
End Sub
Private Sub CommandButton2_Click()
' Bouton Annuler
If a1 = False Then
UserForm1.Hide
End If
End Sub
Private Sub CommandButton3_Click()
' Bouton Bloquer/Autoriser
If a2 = False Then
a2 = True: a1 = True
CommandButton3.Caption = "Bloquer"
Else
a2 = False: a1 = False
CommandButton3.Caption = "Autoriser"
ComboBox1.SetFocus
End If
End Sub
Private Sub UserForm_Activate()
Worksheets("Feuil1").Activate
co1 = ActiveCell.Column: li1 = ActiveCell.Row
If co1 = 1 Then
Me.ComboBox1.ListIndex = -1
ComboBox1.SetFocus
End If
End Sub
Private Sub UserForm_Initialize()
Me.ComboBox1.RowSource = "Feuil2!A1:A" & Sheets("Feuil2").Cells(1, 1).End(xlDown).Row
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If a2 = False Then
Cancel = False
Else
Cancel = True
End If
End Sub |
Partager