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
| Option Explicit
Dim Ws As Worksheet
Private Sub ComboBox1_Change()
'Private Sub ComboBox1_Change()
Dim plage As Range
Dim cell As Range
Dim codrecherché
Set plage = Sheets("études").Range("A2:A" & [A65536].End(xlUp).Row)
codrecherché = ComboBox1.Value
If Me.ComboBox1.ListIndex = -1 Then Exit Sub
For Each cell In plage
If cell.Value = codrecherché Then
TextBox1.Value = Cells(cell.Row, 2)
TextBox2.Value = Cells(cell.Row, 3)
ComboBox2.Value = Cells(cell.Row, 4)
TextBox3.Value = Cells(cell.Row, 5)
TextBox4.Value = Cells(cell.Row, 6)
Texbox5.Value = Cells(cell.Row, 7)
ComboBox3.Value = Cells(cell.Row, 8)
ComboBox4.Value = Cells(cell.Row, 9)
TextBox6.Value = Cells(cell.Row, 10)
ComboBox5.Value = Cells(cell.Row, 11)
TextBox7.Value = Cells(cell.Row, 12)
ComboBox6.Value = Cells(cell.Row, 13)
ComboBox7.Value = Cells(cell.Row, 14)
ComboBox8.Value = Cells(cell.Row, 15)
ComboBox9.Value = Cells(cell.Row, 16)
TextBox8.Value = Cells(cell.Row, 17)
ComboBox10.Value = Cells(cell.Row, 18)
'continuer à remplir les autres textbox
End If
Next cell
End Sub
Private Sub ComboBox8_Change()
End Sub
Private Sub CommandButton1_Click()
' Valider
Dim Ligne As Long
Dim I As Integer
Dim myPassword As String
myPassword = "Lise1234"
ThisWorkbook.Sheets("études").Unprotect Password:=myPassword
If MsgBox("Etes-vous certain de vouloir MODIFIER cette étude ?", vbYesNo, "Demande de confirmation") = vbYes Then 'condition : si oui au message
If Me.ComboBox1.ListIndex = -1 Then Exit Sub
Ligne = Me.ComboBox1.ListIndex + 2
For I = 1 To 17
If Me.Controls("TextBox" & "combobox" & I).Visible = True Then
Ws.Cells(Ligne, I + 1) = Me.Controls("TextBox" & "Combobox" & I)
End If
Next I
MsgBox ("Etude modifiée") 'Vous informant que le présent contact est insérer dans votre tableau Excel.
Unload Me ' Vide et ferme l'Userform ( formulaire)
ThisWorkbook.Sheets("études").Protect Password:=myPassword
End If
End Sub
Private Sub CommandButton2_Click()
Unload Mod_Fournisseur
End Sub
Private Sub Label1_Click()
End Sub
Private Sub TextBox1_Change()
End Sub
Private Sub TextBox7_Change()
End Sub
Private Sub UserForm_Initialize()
Dim J As Long
Dim I As Integer
Set Ws = Sheets("études")
With Me.ComboBox1
For J = 2 To Ws.Range("A" & Rows.Count).End(xlUp).Row
.AddItem Ws.Range("A" & J)
Next J
End With
For I = 1 To 17
Me.Controls("TextBox" & I).Visible = False
ReDim Preserve kase(I)
Set kase(I).Bouton = Me.Controls("CheckBox" & I)
Next I
End Sub |
Partager