XL 2013 Erreur 381 LIST.INDEX

ifi77

XLDnaute Occasionnel
Bonjour @ tous,

un problème surement très simple mais je n'arrive pas à le résoudre.
J'essaie d'alimenter simplement des listbox mais je ne sais pas pourquoi certaines ne fonctionnent pas.
De plus, j'aimerais ne pas faire apparaitre la ligne 1 de la colonne sur la page excel lorsque que la colonne est vide sous le titre.

En pièce jointe le fichier, je sais que pour beaucoup la solution sera très simple mais la je sèche.

Merci
 

Pièces jointes

  • PB LISTBOX.xlsx
    14.1 KB · Affichages: 24

Paf

XLDnaute Barbatruc
Re : Erreur 381 LIST.INDEX

Bonjour

a priori le code est resté dans le classeur .xlsm

J'essaie d'alimenter simplement des listbox mais je ne sais pas pourquoi certaines ne fonctionnent pas.

on trouvera lesquelles!


De plus, j'aimerais ne pas faire apparaitre la ligne 1 de la colonne sur la page excel lorsque que la colonne est vide sous le titre.

si j'ai bien compris :

en A1 : =SI(A2<>"";"CAGOULE -1";"") à adapter aux autres colonnes

A+
 

jecherche

XLDnaute Occasionnel
Re : Erreur 381 LIST.INDEX

Bonsoir,

Un essai ...
Code:
Private Sub UserForm_Initialize()

On Error Resume Next
With Sheets("NBR_EPI")
     If Range("A65536").End(xlUp).Row > 1 Then ListBox6.List() = .Range("A2:A" & .Range("A65536").End(xlUp).Row).Value
     If Range("B65536").End(xlUp).Row > 1 Then ListBox7.List() = .Range("B2:B" & .Range("B65536").End(xlUp).Row).Value
     If Range("C65536").End(xlUp).Row > 1 Then ListBox3.List() = .Range("C2:C" & .Range("C65536").End(xlUp).Row).Value
     If Range("D65536").End(xlUp).Row > 1 Then ListBox4.List() = .Range("D2:D" & .Range("D65536").End(xlUp).Row).Value
     If Range("E65536").End(xlUp).Row > 1 Then ListBox5.List() = .Range("E2:E" & .Range("E65536").End(xlUp).Row).Value
     If Range("F65536").End(xlUp).Row > 1 Then ListBox8.List() = .Range("F2:F" & .Range("F65536").End(xlUp).Row).Value
     If Range("G65536").End(xlUp).Row > 1 Then ListBox9.List() = .Range("G2:G" & .Range("G65536").End(xlUp).Row).Value
     If Range("H65536").End(xlUp).Row > 1 Then ListBox10.List() = .Range("H2:H" & .Range("H65536").End(xlUp).Row).Value
     
     If Range("A65536").End(xlUp).Row = 2 Then ListBox6.List() = .Range("A2:A3").Value
     If Range("B65536").End(xlUp).Row = 2 Then ListBox7.List() = .Range("B2:B3").Value
     If Range("C65536").End(xlUp).Row = 2 Then ListBox3.List() = .Range("C2:C3").Value
     If Range("D65536").End(xlUp).Row = 2 Then ListBox4.List() = .Range("D2:D3").Value
     If Range("E65536").End(xlUp).Row = 2 Then ListBox5.List() = .Range("E2:E3").Value
     If Range("F65536").End(xlUp).Row = 2 Then ListBox8.List() = .Range("F2:F3").Value
     If Range("G65536").End(xlUp).Row = 2 Then ListBox9.List() = .Range("G2:G3").Value
     If Range("H65536").End(xlUp).Row = 2 Then ListBox10.List() = .Range("H2:H3").Value
End With
End Sub

Jecherche
 

jecherche

XLDnaute Occasionnel
Re : Erreur 381 LIST.INDEX

Bonjour,

Je me rends compte que je n'ai pas donné d'explication.
En première partie ">1" sert à éliminer la 1e ligne comme demandé.
En deuxième partie "=2" sert à traiter le fait que les listbox donnaient l'erreur 381 quand il n'y a qu'un item à ajouter.
En utilisant "On error resume next", on outre passe l'erreur 381, mais l'item ne s'inscrivait pas dans le listbox.

Il y a sûrement du code bien meilleur, mais hors ma portée.
Si ça fonctionne, je suis bien heureux.

Bon projet 8- ))


Jecherche
 

Discussions similaires

Réponses
7
Affichages
228

Statistiques des forums

Discussions
311 711
Messages
2 081 799
Membres
101 818
dernier inscrit
tiftouf5757