OVH Cloud OVH Cloud

Erreurd'eéxcution 70 Accès refusé

1 réponse
Avatar
François
Bonjour,

Est-ce quelqu'un saurait comment corriger cette erreur dans le code suivant
:

Private Sub test()
Dim tabtemp As Variant
Dim O, N As Integer
Dim Cell As Range

With Worksheets("Inventaire")
O = .Range("a15000").End(xlUp).Row
tabtemp = .Range("A2:ag" & O).Value
End With

For O = 1 To UBound(tabtemp, 1)
If tabtemp(O, 1) = CStr(Me.ComboBox1.Value) And tabtemp(O, 2) =
CStr(Me.ComboBox2.Value) _
And tabtemp(O, 3) = CStr(Me.ComboBox3.Value) Then

For N = 1 To 30
If tabtemp(O, N + 3) <> "" Then
If N = 5 Or N = 30 Then
Controls("ListBox" & N).AddItem Format(tabtemp(O, N + 3), "#
##0.00 $")
Else
Controls("ListBox" & N).AddItem tabtemp(O, N + 3) '>>>>>>>>>>>>
L'erreur survient ici lorsque N = 9. Pourquoi ? Si je mets For N = 1 to 8
tout fonctionne.
End If
End If
Next N
End If
Next O

End Sub


Merci de votre aide

1 réponse

Avatar
Youky
salut tardif,
à mon avis le ListBox9 n'existe pas... à savoir qu'il faut aller à ListBox30
ce qui fait 30 listbox, de quoi occuper l'index de la main droite un brin de
temps
Youky
"François" a écrit dans le message de news:
12c1g.70980$
Bonjour,

Est-ce quelqu'un saurait comment corriger cette erreur dans le code
suivant :

Private Sub test()
Dim tabtemp As Variant
Dim O, N As Integer
Dim Cell As Range

With Worksheets("Inventaire")
O = .Range("a15000").End(xlUp).Row
tabtemp = .Range("A2:ag" & O).Value
End With

For O = 1 To UBound(tabtemp, 1)
If tabtemp(O, 1) = CStr(Me.ComboBox1.Value) And tabtemp(O, 2) =
CStr(Me.ComboBox2.Value) _
And tabtemp(O, 3) = CStr(Me.ComboBox3.Value) Then

For N = 1 To 30
If tabtemp(O, N + 3) <> "" Then
If N = 5 Or N = 30 Then
Controls("ListBox" & N).AddItem Format(tabtemp(O, N + 3), "#
##0.00 $")
Else
Controls("ListBox" & N).AddItem tabtemp(O, N + 3)
'>>>>>>>>>>>> L'erreur survient ici lorsque N = 9. Pourquoi ? Si je mets
For N = 1 to 8 tout fonctionne.
End If
End If
Next N
End If
Next O

End Sub


Merci de votre aide