Macro en Excel
Résolu
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
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 -
Cher ami,
merci pour vos informations. mon problèe est maintenant résolu Grace à l'instruuction (Me(".....) Encore merci
Pierre