Bonjour à tous !

Je souhaiterais lister les informations contenues dans un fichier excel
à travers un formulaire, des textbox et une combolist

Voici le code surlequel je me suis basé ... mais apparement il comporte quelques soucis
pourriez vous svp m' expliquer ce que je dois modifier ?

En vous remerciant pour vos conseils

Jean-Marc


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
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
'
 
Option Explicit
Dim Ws As Worksheet
 
 
'Correspond au programme du bouton QUITTER
Private Sub CommandButton1_Click()
 
Unload Me
End Sub
 
 
Private Sub SpinButton1_Change()
Range("G15").Value = SpinButton1.Value
End Sub
 
Private Sub TextBox2_Change()
ComboBox1.Value = Ws.Range("A2")
 
 
End Sub
 
Private Sub TextBox3_Change()
 
 
End Sub
 
Private Sub TextBox4_Change()
 
 
 
End Sub
 
Private Sub TextBox5_Change()
 
End Sub
 
Private Sub TextBox6_Change()
 
End Sub
 
Private Sub TextBox9_Change()
 
End Sub
 
'Correspond au programme du FORMULAIRE
Private Sub UserForm_Initialize()
Dim J As Long
Dim I As Integer
 
 
Set Ws = Sheets("FICHIER ADRESSES") 'Attention ce nom doit correspondre au nom de votre ONGLET
 
 With Me.ComboBox1
    For J = 2 To Ws.Range("A" & Rows.Count).End(xlUp).Row
     ' .AddItem Ws.Range("A" & J)
 
 
    Next J
 End With
 
 
ComboBox1.Value = Ws.Range("A2")
TextBox2.Value = Ws.Range("B2")
TextBox3.Value = Ws.Range("C2")
TextBox4.Value = Ws.Range("D2")
TextBox5.Value = Ws.Range("E2")
TextBox6.Value = Ws.Range("F2")
TextBox7.Value = Ws.Range("G2")
TextBox8.Value = Ws.Range("H2")
TextBox9.Value = Ws.Range("I2")
 
 
 
 For I = 1 To 8
'Me.Controls("TextBox" & I).Visible = True 'affiche les données dans les textbox
Next I
End Sub
 
 
'Correspond au programme du bouton MODIFIER
Private Sub CommandButton2_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.ComboBox1.ListIndex = -1 Then Exit Sub
  LIGNE = Me.ComboBox1.ListIndex + 2
  For I = 1 To 8
    If Me.Controls("TextBox" & I).Visible = True Then
      Ws.Cells(LIGNE, I + 1) = Me.Controls("TextBox" & I)
    End If
  Next I
    End If
'Code permettant de modifier le format de la plage de cellule en format nombre
With Ws.Range("D2:d10")
            .NumberFormat = "0"
            .Value = .Value
End With
End Sub
 
'Correspond au programme de la LISTE DEROULANTE
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
  For I = 1 To 8
   ' Me.Controls("TextBox" & I) = Ws.Cells(LIGNE, I + 1)
  Next I
 End Sub