Modifier une série de controle sur une feuille VBA
1 réponse
giom72
Bonjour,
En fait j'ai plusieurs Combobox sur une feuille Excel et je voudrais en
modifier plusieurs d'un seul coup.J'ai essayé ça :
For i = 1 To 20
Controls("CommandButton" & i).Caption = "Bouton "&i
Next i
puis ça :
'For Each ctrl In Feuil1.Controls
' If Left(ctrl.Name, 13) Like "CommandButton" Then ctrl.Caption =
"hello"
' Next
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
isabelle
Bonjour giom72,
Sub Macro1() Dim ctrl, i As Integer For Each sh In Sheets("Feuil1").OLEObjects i = i + 1 If Left(sh.Object.Caption, 13) Like "CommandButton" Then sh.Object.Caption = "Bouton " & i Next End Sub
isabelle
Bonjour,
En fait j'ai plusieurs Combobox sur une feuille Excel et je voudrais en modifier plusieurs d'un seul coup.J'ai essayé ça : For i = 1 To 20 Controls("CommandButton" & i).Caption = "Bouton "&i Next i puis ça :
'For Each ctrl In Feuil1.Controls ' If Left(ctrl.Name, 13) Like "CommandButton" Then ctrl.Caption = "hello" ' Next
Rien à faire il ne trouve pa smes controles
Bonjour giom72,
Sub Macro1()
Dim ctrl, i As Integer
For Each sh In Sheets("Feuil1").OLEObjects
i = i + 1
If Left(sh.Object.Caption, 13) Like "CommandButton" Then sh.Object.Caption = "Bouton " & i
Next
End Sub
isabelle
Bonjour,
En fait j'ai plusieurs Combobox sur une feuille Excel et je voudrais en
modifier plusieurs d'un seul coup.J'ai essayé ça :
For i = 1 To 20
Controls("CommandButton" & i).Caption = "Bouton "&i
Next i
puis ça :
'For Each ctrl In Feuil1.Controls
' If Left(ctrl.Name, 13) Like "CommandButton" Then ctrl.Caption =
"hello"
' Next
Sub Macro1() Dim ctrl, i As Integer For Each sh In Sheets("Feuil1").OLEObjects i = i + 1 If Left(sh.Object.Caption, 13) Like "CommandButton" Then sh.Object.Caption = "Bouton " & i Next End Sub
isabelle
Bonjour,
En fait j'ai plusieurs Combobox sur une feuille Excel et je voudrais en modifier plusieurs d'un seul coup.J'ai essayé ça : For i = 1 To 20 Controls("CommandButton" & i).Caption = "Bouton "&i Next i puis ça :
'For Each ctrl In Feuil1.Controls ' If Left(ctrl.Name, 13) Like "CommandButton" Then ctrl.Caption = "hello" ' Next