Bonjour le Forum,
J'ai un petit problème avec la modification de ma ListBox. Je vous explique ...
J'affiche ma ListBox venant de ma base données avec des combobox pour trier, jusque là tout va bien, cela affiche bien mes données dans les combobox et textbox de mon formulaire.
Ensuite je modifie mes textbox et combobox et je tente de renvoyer le tout dans mon tableau en cliquant sur le bouton modifier
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 Private Sub UserForm_Initialize() Set f = Sheets("BDD 2") Set Rng = f.Range("A3:EW" & f.[A65000].End(xlUp).Row) ' BD à adapter NomTableau = "Tableau2" ActiveWorkbook.Names.Add Name:=NomTableau, RefersTo:=Rng BD = Rng.Value ColCombo = Array(56, 77, 79) colVisu = Array(1, 56, 3, 5, 75, 76, 77, 79, 80, 93, 78) ' colonnes à visualiser (adapter) Ncol = UBound(colVisu) + 1 Me.ComboBox1 = "*" Me.ComboBox2 = "*" Me.ComboBox3 = "*" TextBox5.List() = Array("Oui", "Non", "xxx") TextBox6.List() = Array("Accident de Travail", "Arrêt Maladie", "CMA Non Conformes", "Cumul Emploi Retraite", "Evaluation Licenciement", "Limite Dérog. Ou Agrément atteinte", "ERDAF", "PEC Difficile", "A.F.R", "xxx") Affiche B_Raz_Click End Sub
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 Private Sub CommandButton1_Click() Dim P$, Qln% With ListBox1 If .ListIndex = -1 Then Exit Sub Ln = .List(.ListIndex, 0) End With P5 = TextBox5 [Tableau2].Cells(Ln, 75) = P5 P6 = TextBox6 [Tableau2].Cells(Ln, 76) = P6 If TextBox7 = "" Then [Tableau2].Cells(Ln, 77) = TextBox7 'ou = 0 ou ce que tu veux! ElseIf IsDate(TextBox7) Then [Tableau2].Cells(Ln, 77) = CDate(TextBox7) End If If TextBox8 = "" Then [Tableau2].Cells(Ln, 79) = TextBox8 'ou = 0 ou ce que tu veux! ElseIf IsDate(TextBox8) Then [Tableau2].Cells(Ln, 79) = CDate(TextBox8) End If P9 = TextBox9 [Tableau2].Cells(Ln, 80) = P9 P10 = TextBox10 [Tableau2].Cells(Ln, 93) = P10 P11 = TextBox11 [Tableau2].Cells(Ln, 78) = P11 MsgBox "Modifications Effectuées !" Me.ComboBox1 = "*" Me.ComboBox2 = "*" Me.ComboBox3 = "*" UserForm_Initialize End Sub
Le problème intervient ici, les données sont modifiées mais pas sur la bonne ligne dans mon tableau excel cela modifie les données mais sur 4 lignes au dessus. Est ce un problème d'indexage ?
Merci pour votre aide car je m'y perd un peu dans mon code ...
Partager