Macro en Excel
Résolu
Boschmanspi
Messages postés
73
Date d'inscription
Statut
Membre
Dernière intervention
-
Boschmanspi Messages postés 73 Date d'inscription Statut Membre Dernière intervention -
Boschmanspi Messages postés 73 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
Merci d'avance pour votre réponse.
Cette routine (partie de macro) en excel devrait pouvoir initiiler les labels si .Labl1 pouvait devenir .Label2, Label3 .... suivant I. Est-ce possible ?
' For I = 1 To 10
' .Label1.Caption = Worksheets("Data").Cells(1, I)
' Next I
Merci d'avance pour votre réponse.
Cette routine (partie de macro) en excel devrait pouvoir initiiler les labels si .Labl1 pouvait devenir .Label2, Label3 .... suivant I. Est-ce possible ?
' For I = 1 To 10
' .Label1.Caption = Worksheets("Data").Cells(1, I)
' Next I
A voir également:
- Macro en Excel
- Telecharger macro convertir chiffre en lettre excel - Télécharger - Tableur
- Liste déroulante excel - Guide
- Mise en forme conditionnelle excel - Guide
- Word et excel gratuit - Guide
- Déplacer colonne excel - Guide
2 réponses
Bonjour,
'contrôles dans une feuille de calcul
Private Sub CommandButton1_Click()
Dim Obj As OLEObject
'boucle sur la Feuil1
For Each Obj In Sheets("Feuil1").OLEObjects
'verifie s'il s'agit d'un Label
If TypeOf Obj.Object Is MSForms.Label Then
I = CInt(Mid(Obj.Name, 6, 2))
Obj.Object.Caption = Worksheets("Data").Cells(1, I)
End If
Next Obj
End Sub
'contrôles dans UserForm
Private Sub CommandButton2_Click()
Dim Cont As Control
'Boucle sur UF
For Each Cont In Me.Controls
'verifie s'il s'agit d'un Label
If TypeOf Cont Is MSForms.Label Then
I = CInt(Mid(Cont.Name, 6, 2))
Cont.Object.Caption = Worksheets("Data").Cells(1, I)
End If
Next Cont
End Sub
'ou
'contrôles dans UserForm
Private Sub CommandButton3_Click()
For I = 1 To 30
Me("Label" & I).Caption = Worksheets("Data").Cells(1, I)
Next I
End If
Bonne suite
'contrôles dans une feuille de calcul
Private Sub CommandButton1_Click()
Dim Obj As OLEObject
'boucle sur la Feuil1
For Each Obj In Sheets("Feuil1").OLEObjects
'verifie s'il s'agit d'un Label
If TypeOf Obj.Object Is MSForms.Label Then
I = CInt(Mid(Obj.Name, 6, 2))
Obj.Object.Caption = Worksheets("Data").Cells(1, I)
End If
Next Obj
End Sub
'contrôles dans UserForm
Private Sub CommandButton2_Click()
Dim Cont As Control
'Boucle sur UF
For Each Cont In Me.Controls
'verifie s'il s'agit d'un Label
If TypeOf Cont Is MSForms.Label Then
I = CInt(Mid(Cont.Name, 6, 2))
Cont.Object.Caption = Worksheets("Data").Cells(1, I)
End If
Next Cont
End Sub
'ou
'contrôles dans UserForm
Private Sub CommandButton3_Click()
For I = 1 To 30
Me("Label" & I).Caption = Worksheets("Data").Cells(1, I)
Next I
End If
Bonne suite