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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
| Option Explicit
Dim Ws As Worksheet
'Pour le bouton prêt
Private Sub CommandButton10_Click()
Sheets("Prêt").Select
Dim Ctrl As Control
For Each Ctrl In Me.Controls
If TypeName(Ctrl) = "TextBox" Then Ctrl.Text = ""
If TypeName(Ctrl) = "ComboBox" Then Ctrl.Text = ""
Next Ctrl
End Sub
'Pour le bouton PC-M73
Private Sub CommandButton11_Click()
Sheets("PC-M73").Select
Dim Ctrl As Control
For Each Ctrl In Me.Controls
If TypeName(Ctrl) = "TextBox" Then Ctrl.Text = ""
If TypeName(Ctrl) = "ComboBox" Then Ctrl.Text = ""
Next Ctrl
End Sub
'Pour le bouton Ecran
Private Sub CommandButton5_Click()
Sheets("Ecran").Activate
Dim Ctrl As Control
For Each Ctrl In Me.Controls
If TypeName(Ctrl) = "TextBox" Then Ctrl.Text = ""
If TypeName(Ctrl) = "ComboBox" Then Ctrl.Text = ""
Next Ctrl
End Sub
'Pour le bouton Vider
Private Sub CommandButton12_Click()
Dim Ctrl As Control
For Each Ctrl In Me.Controls
If TypeName(Ctrl) = "TextBox" Then Ctrl.Text = ""
If TypeName(Ctrl) = "ComboBox" Then Ctrl.Text = ""
Next Ctrl
End Sub
'Pour le bouton UC
Private Sub CommandButton4_Click()
Sheets("UC").Select
Dim Ctrl As Control
For Each Ctrl In Me.Controls
If TypeName(Ctrl) = "TextBox" Then Ctrl.Text = ""
If TypeName(Ctrl) = "ComboBox" Then Ctrl.Text = ""
Next Ctrl
End Sub
'Pour le bouton Portable
Private Sub CommandButton6_Click()
Sheets("Portable").Select
Dim Ctrl As Control
For Each Ctrl In Me.Controls
If TypeName(Ctrl) = "TextBox" Then Ctrl.Text = ""
If TypeName(Ctrl) = "ComboBox" Then Ctrl.Text = ""
Next Ctrl
End Sub
'Pour le bouton Imprimante
Private Sub CommandButton7_Click()
Sheets("Imprimante").Select
Dim Ctrl As Control
For Each Ctrl In Me.Controls
If TypeName(Ctrl) = "TextBox" Then Ctrl.Text = ""
If TypeName(Ctrl) = "ComboBox" Then Ctrl.Text = ""
Next Ctrl
End Sub
'Pour le bouton Stock
Private Sub CommandButton8_Click()
Sheets("Stock").Select
Dim Ctrl As Control
For Each Ctrl In Me.Controls
If TypeName(Ctrl) = "TextBox" Then Ctrl.Text = ""
If TypeName(Ctrl) = "ComboBox" Then Ctrl.Text = ""
Next Ctrl
End Sub
'Pour le bouton Réformé
Private Sub CommandButton9_Click()
Sheets("Reforme").Select
Dim Ctrl As Control
For Each Ctrl In Me.Controls
If TypeName(Ctrl) = "TextBox" Then Ctrl.Text = ""
If TypeName(Ctrl) = "ComboBox" Then Ctrl.Text = ""
Next Ctrl
End Sub
'Pour le formulaire
Private Sub UserForm_Initialize()
Dim J As Long
ComboBox2.List() = Array("Paris", "Reims", "Autre")
Set Ws = Sheets("UC") 'Correspond au nom de l'onglet dans le ficier Excel
With Me.ComboBox1
For J = 2 To Ws.Range("A" & Rows.Count).End(xlUp).Row
.AddItem Ws.Range("A" & J)
Next
End With
End Sub
'Pour la feuille UC de la liste déroulante ref
Private Sub ComboBox1_Change()
Dim Ligne As Long
Dim I As Integer
If Me.ComboBox1.ListIndex = -1 Then Exit Sub
Ligne = Me.ComboBox1.ListIndex + 2
ComboBox2 = Ws.Cells(Ligne, "B")
For I = 1 To 12
Me.Controls("TextBox" & I) = Ws.Cells(Ligne, I + 2)
Next I
End Sub
'Pour le bouton Nouveau
Private Sub CommandButton1_Click()
Dim L As Integer
If MsgBox("Confirmez-vous l'insertion de ce nouvel utilisateur?", vbYesNo, "Demande de confirmation d'ajout") = vbYes Then
L = Sheets("UC").Range("A" & Rows.Count).End(xlUp).Row + 1 'Pour placer le nouvel enregistrement la premire ligne de tableau non Vide
Range("A" & L).Value = ComboBox1
Range("B" & L).Value = ComboBox2
Range("C" & L).Value = TextBox1
Range("D" & L).Value = TextBox2
Range("E" & L).Value = TextBox3
Range("F" & L).Value = TextBox4
Range("G" & L).Value = TextBox5
Range("H" & L).Value = TextBox6
Range("I" & L).Value = TextBox7
Range("J" & L).Value = TextBox8
Range("K" & L).Value = TextBox9
Range("L" & L).Value = TextBox10
Range("M" & L).Value = TextBox11
Range("N" & L).Value = TextBox12
Dim J As Long
Dim I As Integer
ComboBox1.Clear
Set Ws = Sheets("UC") 'Correspond au nom de l'onglet de la feuille Excel
With Me.ComboBox1
For J = 2 To Ws.Range("A" & Rows.Count).End(xlUp).Row
.AddItem Ws.Range("A" & J)
Next J
End With
Else
End If
Dim Ctrl As Control
For Each Ctrl In Me.Controls
If TypeName(Ctrl) = "TextBox" Then Ctrl.Text = ""
If TypeName(Ctrl) = "ComboBox" Then Ctrl.Text = ""
Next Ctrl
End Sub
'Pour le bouton Modifier
Private Sub CommandButton2_Click()
Dim Ligne As Long
Dim I As Integer
If MsgBox("Confirmez-vous les modifications?", vbYesNo, "Demande de confirmation de modification") = vbYes Then
If Me.ComboBox1.ListIndex = -1 Then Exit Sub
Ligne = Me.ComboBox1.ListIndex + 2
Ws.Cells(Ligne, "B") = ComboBox2
For I = 1 To 12
Ws.Cells(Ligne, I + 2) = Me.Controls("TextBox" & I)
Next I
End If
End Sub
'Pour le bouton Quitter
Private Sub CommandButton3_Click()
Unload Me
End Sub |
Partager