Précédent   Forum des professionnels en informatique > Logiciels > Microsoft Office > Excel > Macros et VBA Excel
Macros et VBA Excel Vos questions relatives aux macros Excel, à l'utilisation de VBA et à l'automatisation de vos classeurs Excel.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 09/09/2011, 21h20   #1
Nouveau Membre du Club
 
Homme tof tim
Technicien maintenance
Inscription : septembre 2011
Messages : 101
Détails du profil
Informations personnelles :
Nom : Homme tof tim
Localisation : Belgique

Informations professionnelles :
Activité : Technicien maintenance
Secteur : Bâtiment Travaux Publics

Informations forums :
Inscription : septembre 2011
Messages : 101
Points : 39
Points : 39
Par défaut créer une boucle pour x et y

bonsoir,
je ne trouve pas comment faire...

vooilà j'aurai voulu créer une boucle pour me permettre de ne pas re-copier à chaque fois ces 7 lignes "sheets

"Feuille2").cells(2,1).value=listeClients.Column(0,ListeClients.List.Index)"

je dois faire une boucle pour 7 lignes, j'aurai voulu faire par exemple ci-dessous

Code :
1
2
3
4
For x = 1 to 7
For y=0 ot 6
"Feuille2").cells(2,x).value=listeClients.Column(y,ListeClients.List.Index)
"
pour eviter ceci :
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 
        Sheets("Feuil2").Cells(2, x).Value = ListeClients.Column(y, ListeClients.ListIndex)
x=x+1
        Sheets("Feuil2").Cells(2, x) = ListeClients.Column(y, ListeClients.ListIndex)
x=x+1
        Sheets("Feuil2").Cells(2, x) = ListeClients.Column(y, ListeClients.ListIndex)
x=x+1
        Sheets("Feuil2").Cells(2, x) = ListeClients.Column(y, ListeClients.ListIndex)
x=x+1
        Sheets("Feuil2").Cells(2, x) = ListeClients.Column(y, ListeClients.ListIndex)
x=x+1
        Sheets("Feuil2").Cells(2, x) = ListeClients.Column(y, ListeClients.ListIndex)
x=x+1
        Sheets("Feuil2").Cells(2, x) = ListeClients.Column(y, ListeClients.ListIndex)
 
End If
Next
Merci pour votre aide à l'avance.

Tim
timtof2011 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 09/09/2011, 21h43   #2
Expert Confirmé Sénior
 
Avatar de mercatog
 
Inscription : juillet 2008
Messages : 5 848
Détails du profil
Informations forums :
Inscription : juillet 2008
Messages : 5 848
Points : 13 907
Points : 13 907
?
Code :
1
2
3
For x = 1 To 7
    Worksheets("Feuille2").Cells(2, x).Value = ListeClients.Column(x - 1, ListeClients.List.Index)
Next x
__________________
Cordialement.
mercatog est déconnecté   Envoyer un message privé Réponse avec citation 20
Vieux 10/09/2011, 02h59   #3
Nouveau Membre du Club
 
Homme tof tim
Technicien maintenance
Inscription : septembre 2011
Messages : 101
Détails du profil
Informations personnelles :
Nom : Homme tof tim
Localisation : Belgique

Informations professionnelles :
Activité : Technicien maintenance
Secteur : Bâtiment Travaux Publics

Informations forums :
Inscription : septembre 2011
Messages : 101
Points : 39
Points : 39
Par défaut Créer un boucle avec x et y

Merci beaucoup avec un peu de recherche et votre aide ça fonctionne...
bon week end.

tim
timtof2011 est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 01h31.


 
 
 
 
Partenaires

Hébergement Web