probleme de variable reaffecte de variable

L

LOREAUX

Guest
j'ai 24 listbox allant de listbox1 à listbox24
et 24 variable NOM allant de ChoixNOM1 à ChoixNOM24
JE SUIS OBLIGE D'ECRIRE 24 FOIS LE MEME CODE INCREMENTE DE 1 A 24 CHAQUE FOIS EX:

LstNOM1 = Range("B2").End(xlDown).Address
ListBox1.RowSource = "B2:" & LstNOM1
ListBox1.ListIndex = 0
........
ListBox24.RowSource = "B2:" & LstNOM1
ListBox24.ListIndex = 0

Range("F8").select
Index1 = ListBox1.ListIndex
ChoixNOM1 = ListBox1.List(Index1)
ActiveCell = ChoixNOM1 'variable NOM

ActiveCell.Offset(ROWOFFSET:=1, columnoffset:=0).Activate
.......
Index24 = ListBox24.ListIndex
ChoixNOM24 = ListBox24.List(Index24)
ActiveCell = ChoixNOM24
.

****************************

est-il possible en faisant une boucle FOR I=1 TO 24 .....NEXT I
d'affecter "I" par incrementation à
LstNOM, ListBox, Index, ChoixNOM
sous la forme
********
FOR I=1 TO 24

LstNOM & I = Range("B2").End(xlDown).Address
ListBox & I.RowSource = "B2:" & LstNOM & I
ListBox & I.ListIndex = 0
........
LstNOM & I.RowSource = "B2:" & LstNOM & I
ListBox & I.ListIndex = 0

Range("F8").select
Index & I = ListBox & I.ListIndex
ChoixNOM & I = ListBox & I.List(Index1)
ActiveCell = ChoixNOM & I 'variable NOM

ActiveCell.Offset(ROWOFFSET:=1, columnoffset:=0).Activate
.......
Index & I = ListBox & I.ListIndex
ChoixNOM & I = ListBox & I.List(Index1)
ActiveCell = ChoixNOM & I 'variable NOM

NEXT I
J'AI TOUT ESSAYE MAIS RIEN NE MARCHE
QUELQU'UN A T'IL UNE SOLUTION. MERCI
 
S

sylsyl

Guest
Salut Loreaux,

cette question a deja etait posee. Je pense que la meilleure reponse etait un truc du genre:

For i = 1 to 24
Control("Listbox" & i).Rowsource=...

mais peut-etre etait-ce Controls() ?

Essai comme ca et si ca ne marche pas tu peux toujours chercher l'ancien poste (cherche dans les 30 derniers jours, je crois que ca devrait suffire).

Tiens moi au courant...

A++, Sylsyl.
 

Discussions similaires

Membres actuellement en ligne

Aucun membre en ligne actuellement.

Statistiques des forums

Discussions
312 321
Messages
2 087 265
Membres
103 501
dernier inscrit
talebafia