Bon, pour le vidage des Ranges à l'ouverture de la Form :
1 2 3 4 5 6 7 8 9
|
Private Sub UserForm_Initialize()
'ComboBox1.Clear <--- totalement inutile !
ComboBox1.List = Application.Transpose(Range("MFA"))
'ComboBox2.Clear <--- totalement inutile car au lancement de la Form, ils sont vides !
Sheets("Model").Range("D17:G20", "G11:H13").ClearContents
End Sub |
Effectivement, Merci !!!
et le vidage des contrôles sur le bouton Refresh :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
Private Sub CommandButton6_Click()
Sheets("Model").Range("D17:G20", "G11:H13").ClearContents
ComboBox1.Clear
ComboBox2.Clear
TextBox6.Text = ""
TextBox7.Text = ""
TextBox8.Text = ""
TextBox9.Text = ""
'chercher une commande pour effacer les combocox
End Sub |
En effet, j'avais essayé ce codage, cependant j'ai le mmême message d'erreur :
Erreur d'éxecution '1004'
Impossible de lire la propriété Vlookup de la classe WorkSheetFunction
Ensuite il m'envoie à cette partie de mon codage qui va chercher la valeur d'une cellule en fonction de ma textBox18.
Private Sub TextBox18_Change()
Dim myRange As Range
Set myRange = Worksheets("variablesX").Range("A8:I52")
TextBox2.Value = Application.WorksheetFunction.VLookup(TextBox18.Value, myRange, 2, False)
TextBox10.Value = Application.WorksheetFunction.VLookup(TextBox18.Value, myRange, 3, False)
TextBox3.Value = Application.WorksheetFunction.VLookup(TextBox18.Value, myRange, 4, False)
TextBox11.Value = Application.WorksheetFunction.VLookup(TextBox18.Value, myRange, 5, False)
TextBox4.Value = Application.WorksheetFunction.VLookup(TextBox18.Value, myRange, 6, False)
TextBox12.Value = Application.WorksheetFunction.VLookup(TextBox18.Value, myRange, 7, False)
TextBox5.Value = Application.WorksheetFunction.VLookup(TextBox18.Value, myRange, 8, False)
TextBox13.Value = Application.WorksheetFunction.VLookup(TextBox18.Value, myRange, 9, False)
Dim myRange2 As Range
Set myRange2 = Worksheets("Ranges_2").Range("A2:I46")
TextBox14.Value = Application.WorksheetFunction.VLookup(TextBox18.Value, myRange2, 3, False)
TextBox15.Value = Application.WorksheetFunction.VLookup(TextBox18.Value, myRange2, 5, False)
TextBox16.Value = Application.WorksheetFunction.VLookup(TextBox18.Value, myRange2, 7, False)
TextBox17.Value = Application.WorksheetFunction.VLookup(TextBox18.Value, myRange2, 9, False)
End Sub
J'ai essayé d'autres commandes, mais ça devient complexe

Merci pour la rapidité des réponses !!!
Lucas
Partager