Modifier code

Bonjour

Je cherche à modifier mon code et je me rencontre que mon code n'est pas très esthétique je voulais savoir si on pouvais le raccourcir.. oui je suis sur que l'on peux ?

Private Sub UserForm_Initialize()
Label1.Visible = False
Label2.Visible = False
Label3.Visible = False
Label4.Visible = False
TBx_1.Visible = False
TBx_2.Visible = False
TBx_3.Visible = False
TBx_4.Visible = False
TBx_5.Visible = False
TBx_6.Visible = False
TBx_7.Visible = False
TBx_8.Visible = False
TBx_9.Visible = False
TBx_10.Visible = False
TBx_11.Visible = False
TBx_12.Visible = False
TBx_13.Visible = False
TBx_14.Visible = False
TBx_15.Visible = False
TBx_16.Visible = False
TBx_17.Visible = False
TBx_18.Visible = False
TBx_19.Visible = False
TBx_20.Visible = False

Me.Width = 425
Me.Height = 83

End Sub

Je vous remercie

max

Bonjour valmax,

Voici une simplification:

Private Sub UserForm_Initialize()

For i=1 to 4
    Label(i).Visible = False
Next i

For i=1 to 20
    TBx_(i).Visible = False
Next i

Me.Width = 425
Me.Height = 83

End Sub

Bonjour Florian

Je te remercie nickel.

Peut tu me dire pourquoi dans mon code j'ai ceci

Private Sub ComboBox1_Change()
TBx_1.Value = ComboBox1.Column(1)
TBx_2.Value = ComboBox1.Column(2)
TBx_3.Value = ComboBox1.Column(3)
TBx_4.Value = ComboBox1.Column(4)
TBx_5.Value = ComboBox1.Column(5)
TBx_6.Value = ComboBox1.Column(6)
TBx_7.Value = ComboBox1.Column(7)
TBx_8.Value = ComboBox1.Column(8)
TBx_9.Value = ComboBox1.Column(9)
TBx_10.Value = ComboBox1.Column(10)
TBx_11.Value = ComboBox1.Column(11)
TBx_12.Value = ComboBox1.Column(12)
TBx_13.Value = ComboBox1.Column(13)
TBx_14.Value = ComboBox1.Column(14)
TBx_15.Value = ComboBox1.Column(15)
TBx_16.Value = ComboBox1.Column(16)
TBx_17.Value = ComboBox1.Column(17)
TBx_18.Value = ComboBox1.Column(18)
TBx_19.Value = ComboBox1.Column(19)
TBx_20.Value = ComboBox1.Column(20)

End Sub

Et à chaque j'ai une erreur sur le TBx_15.Value = ComboBox1.Column(15) ou des fois sur le TBx_20.Value = ComboBox1.Column(20)

Je te remercie

Max

Rechercher des sujets similaires à "modifier code"