Le_Troll_Du_27
XLDnaute Occasionnel
Bonjour le forum
J'ai un tableau de 13 colonnes. (A-M). Mes formules sont dans F, L & M
Voilà mon code :
Et c'est ici que j'ai besoin de comprendre
Dès que je modifie à chaque fois je sort des colonnes pour fini sur Q
Je vous remercie
Cordialement
Laurent
J'ai un tableau de 13 colonnes. (A-M). Mes formules sont dans F, L & M
Voilà mon code :
Code:
Private Sub ComboBox1_Change()
Nettoyage ' ------------------------- Lance le programme Nettoyage
Me.ComboBox2.Clear ' ---------------- Efface les données de la combobox2
If Me.ComboBox1.ListIndex = -1 Then Exit Sub
With Me.ComboBox2
For j = 2 To NbLignes
If Ws.Range("A" & j) = Me.ComboBox1 Then
.AddItem Ws.Range("B" & j)
.List(.ListCount - 1, 1) = j ' - Note numéro de ligne dans la colonne masquée
End If
Next j
End With
TextBox11 = ComboBox1 ' ------------- remplit la texbox11
End Sub
Private Sub ComboBox2_Change()
Dim Ligne As Long
Dim i As Integer
Nettoyage ' ------------------------- Lance le programme Nettoyage
If Me.ComboBox2.ListIndex = -1 Then Exit Sub
Ligne = Me.ComboBox2.List(Me.ComboBox2.ListIndex, 1)
For i = 1 To 10
Me.Controls("TextBox" & i) = Ws.Cells(Ligne, i + 2)
Next i
TextBox11 = ComboBox1 ' ------------- Equipements
TextBox12 = ComboBox2 ' ------------- Désignation
TextBox13 = TextBox1 ' -------------- Référence
TextBox14 = TextBox2 ' -------------- Prix HT
ComboBox3 = TextBox3 ' -------------- Coefficient de revente
TextBox15 = TextBox3 ' -------------- Coefficient de revente
TextBox16 = TextBox4 ' -------------- Prix de revente
TextBox17 = TextBox5 ' -------------- Quantité
TextBox18 = TextBox6 ' -------------- Poids
TextBox19 = TextBox7 ' -------------- Seuil
TextBox20 = TextBox8 ' -------------- Entrée
TextBox21 = TextBox9 ' -------------- Sortie
TextBox22 = TextBox10 ' ------------- Stock Réel
End Sub
Et c'est ici que j'ai besoin de comprendre
Code:
Private Sub CmdB_Modifier_Click()
If MsgBox("Etes-vous certain de vouloir modifier ce produit ?", _
vbYesNo, "Demande de confirmation") = vbYes Then
Dim Ligne As Long
Dim i As Integer
If Me.ComboBox2.ListIndex = -1 Then Exit Sub
Ligne = Me.ComboBox2.List(Me.ComboBox2.ListIndex, 1)
For i = 11 To 15
If Me.Controls("TextBox" & i).Visible = True Then
Ws.Cells(Ligne, i - 2) = Me.Controls("TextBox" & i)
End If
Next i
For i = 17 To 21
If Me.Controls("TextBox" & i).Visible = True Then
Ws.Cells(Ligne, i - 4) = Me.Controls("TextBox" & i)
End If
Next i
End If
End Sub
Sub InitComboBox1()
Dim MonDico As Object
Set MonDico = CreateObject("Scripting.dictionary")
For j = 2 To NbLignes
MonDico(Ws.Range("A" & j).Value) = ""
Next j
With Me.ComboBox1
.Clear
If MonDico.Count > 0 Then
.List = Application.Transpose(MonDico.keys)
End If
End With
End Sub
Private Sub UserForm_Initialize() ' ----- à l'initialisation de l'userform
Dim i As Integer
Set Ws = Worksheets("PRODUIT")
NbLignes = Ws.Range("A65536").End(xlUp).Row
With Me.ComboBox2
.ColumnCount = 2 ' -------------- 2 colonnes
.ColumnWidths = "-1;0" ' -------- Dont une de masquée
End With
InitComboBox1 ' --------------------- Lance le programme Init
For i = 2 To Ws.Range("E65536").End(xlUp).Row
ComboBox3 = Ws.Range("E" & i)
If ComboBox3.ListIndex = -1 Then ComboBox3.AddItem Ws.Range("E" & i)
Next i
Me.ComboBox3.List = ListSort(Me.ComboBox3.List)
' ========== Format des TextBox ==========
TextBox2 = Format(TextBox2, "# ##0.00€")
TextBox3 = Format(TextBox3, "# ##0%")
TextBox4 = Format(TextBox4, "# ##0.00€")
TextBox6 = Format(TextBox6, "# ##0.00Kg")
TextBox14 = Format(TextBox14, "# ##0.00€")
TextBox15 = Format(TextBox15, "# ##0%")
TextBox16 = Format(TextBox16, "# ##0.00€")
End Sub
Dès que je modifie à chaque fois je sort des colonnes pour fini sur Q
Je vous remercie
Cordialement
Laurent
Dernière édition: