Dans ce code j'ai un problème de chemin, un problème sur le boutton4 notamment surCode:
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 Private Sub Combobox1_Change() If ComboBox1.ListIndex <> -1 Then Lg = ComboBox1.ListIndex + 2 For i = 2 To 8 Controls("textbox" & i) = Sheets("feuil1").Cells(Lg, i) Next i End If Creer_img End Sub Private Sub CommandButton1_Click() ' effacer Raz End Sub Private Sub CommandButton2_Click() ' supprimer If MsgBox("etes vous sur de vouloir supprimer cette données?", vbYesNo, "demande de confirmation") = vbYes Then Sheets("feuil1").ListObjects(1).ListRows(ComboBox1.ListIndex + 1).Delete End If Raz UserForm_Initialize End Sub Private Sub CommandButton3_Click() 'modifier For i = 2 To 8 If ComboBox1.ListIndex <> -1 Then Lg = ComboBox1.ListIndex + 2 Sheets("feuil1").Cells(Lg, i).Value = Controls("textbox" & i) End If Next i Raz UserForm_Initialize End Sub Private Sub CommandButton4_Click() ' valider Dim tbl As ListObject If MsgBox("voulez-vous enregistrer dans la base de donnée?", vbYesNo) = vbYes Then Set tbl = Sheets("feuil1").ListObjects(1) Set D = tbl.ListRows.Add.Range(1) With D For i = 1 To 7 .Cells(1, i).Value = Controls("textbox" & i).Value Next i End With End If Raz UserForm_Initialize End Sub Private Sub ListView1_ItemClick(ByVal Item As MSComctlLib.ListItem) Lg = ListView1.SelectedItem.Index TextBox1 = ListView1.SelectedItem.Text For i = 1 To 7 Controls("textbox" & i + 1) = ListView1.ListItems(Lg).ListSubItems(i).Text ComboBox1.Value = ListView1.ListItems(Lg) Next i Creer_img End Sub Private Sub UserForm_Initialize() Dim D As Range affiche_listV With Sheets("feuil1") For Each D In .Range("A2:A" & .Range("A65000").End(xlUp).Row) ComboBox1.AddItem D.Offset(, 0).Value Next D End With End Sub Sub Raz() For i = 1 To 8 Controls("textbox" & i) = "" Next i ComboBox1 = "" Image2.Picture = LoadPicture("") End Sub Sub Creer_img() On Error Resume Next Image2.Picture = LoadPicture("C:\Users\Phanuel\Desktop\ALBUM\" & ComboBox1 & ".JPG") If Err <> 0 Then Image2.Picture = LoadPicture("") End If End Sub
on me ditCode:Set tbl= sheets("feuil1").listobjects
Puis sur le boutton 2Citation:
l'indice n'appartient pas à la sélection.
on me dit la même choseCode:Sheets("feuil1").listobjects(1)listrows(combobox1.listindex+ 1).delete
MODULES
Merci de m'aider si vous pouvez je vous en pris.Code:
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 Option Explicit Public Lg As Long, i As Integer, C As Variant, Lst As ListItem Sub Tbl_Accueil() With Sheets("feuil1") C = .Range("A1:H" & .Range("A65000").End(xlUp).Row).Value End With End Sub Sub affiche_listV() Tbl_Accueil With UserForm1.ListView1 .ListItems.Clear With .ColumnHeaders .Clear .Add , , "code", 30 .Add , , "nom", 120 .Add , , "profession", 80 .Add , , "naissance", 80 .Add , , "contacts", 80 .Add , , "nationalite", 80 .Add , , "village", 80 .Add , , "formation", 80 End With .Gridlines = True .BorderStyle = ccFixedSingle .FullRowSelect = True .View = lvwReport For Lg = 2 To UBound(C) Set Lst = .ListItems.Add(, , C(Lg, 1)) With Lst .ListSubItems.Add , , C(Lg, 2) For i = 3 To 8 .ListSubItems.Add , , C(Lg, i) Next i C(Lg, 4) = Format(C(Lg, 4), "dd/mm/yyyy") End With Next Lg End With End Sub Sub affiche_usf() UserForm1.Show End Sub