Erreur sur formulaire excel

Fermé
jdcoro Messages postés 2 Date d'inscription jeudi 15 décembre 2016 Statut Membre Dernière intervention 15 décembre 2016 - 15 déc. 2016 à 14:46
michel_m Messages postés 16603 Date d'inscription lundi 12 septembre 2005 Statut Contributeur Dernière intervention 16 décembre 2023 - 15 déc. 2016 à 17:08
Bonjour,

Je travaille sur ce fichier depuis longtemps et quand je lance la macro je reçois une erreur qui dit "La méthode" Range de l'objet'_Worksheet 'à Échoué.
S'il vous plaît quelqu'un sait comment résoudre ce problème?

Merci beaucoup :)

Je suis nouveau et je ne sais pas mettre le code sous format code :(

Voila le code:

Option Explicit
Dim Ws As Worksheet
Private Sub UserForm_Initialize()
Dim J As Long
ComboBox2.ColumnCount = 1
ComboBox2.List() = Array(" ", " Development 1 ", " Development 2 ", " Partnership ")
Set Ws = Sheets("RFP")
With Me.ComboBox1
For J = 2 To Ws.Range(" A " & Rows.Count).End(xlUp).Row
.AddItem Ws.Range(" A " & J)
Next J
End With

End Sub

Private Sub ComboBox1_Change()
Dim Ligne As Long
Dim I As Integer
If Me.ComboBox1.ListIndex = -1 Then Exit Sub
Ligne = Me.ComboBox1.ListIndex + 2
ComboBox2 = Ws.Cells(Ligne, " B ")
For I = 1 To 7
Me.Controls(" TextBox " & I) = Ws.Cells(Ligne, I + 2)
Next I
End Sub

Private Sub CommandButton1_Click()
Dim L As Integer
If MsgBox(" Confirmez-vous l’insertion de ce nouveau contrat ? ", vbYesNo, " Demande de confirmation d’ajout ") = vbYes Then
L = Sheets("RFP").Range(" a65536 ").End(xlUp).Row + 1
Range(" A " & L).Value = ComboBox1
Range(" B " & L).Value = ComboBox2
Range(" C " & L).Value = TextBox2
Range(" D " & L).Value = TextBox3
Range(" E " & L).Value = TextBox4
Range(" F " & L).Value = TextBox5
Range(" G " & L).Value = TextBox6
Range(" H " & L).Value = TextBox7

End If
End Sub


Private Sub CommandButton2_Click()
Dim Ligne As Long
Dim I As Integer
If MsgBox(" Confirmez-vous la modification de ce contrat ? ", vbYesNo, " Demande de confirmation de modification ") = vbYes Then
If Me.ComboBox1.ListIndex = -1 Then Exit Sub
Ligne = Me.ComboBox1.ListIndex + 2
Ws.Cells(Ligne, " B ") = ComboBox2
For I = 1 To 7
If Me.Controls(" TextBox " & I).Visible = True Then
Ws.Cells(Ligne, I + 2) = Me.Controls(" TextBox " & I)
End If
Next I
End If
End Sub


Private Sub CommandButton3_Click()
Unload Me
End Sub
A voir également:

2 réponses

michel_m Messages postés 16603 Date d'inscription lundi 12 septembre 2005 Statut Contributeur Dernière intervention 16 décembre 2023 3 303
15 déc. 2016 à 15:49
Bonjour,

sur quelle ligne se produit l'erreur ?
0
jdcoro Messages postés 2 Date d'inscription jeudi 15 décembre 2016 Statut Membre Dernière intervention 15 décembre 2016
15 déc. 2016 à 16:13
Bonjour Michel,

L'erreur se produit sur la troisième ligne :
"Public Sub UserForm_Initialize() "

Merci pour ton aide
0
michel_m Messages postés 16603 Date d'inscription lundi 12 septembre 2005 Statut Contributeur Dernière intervention 16 décembre 2023 3 303
15 déc. 2016 à 17:08
Pourquoi écrire
" A " au lieu de "A"

idem pour tout les codes de l'userform

pour i,itialize
Private Sub UserForm_Initialize()
ComboBox2.ColumnCount = 1
ComboBox2.List() = Array(" ", " Development 1 ", " Development 2 ", " Partnership ")
Set Ws = Sheets("RFP")
With Me.ComboBox1
For J = 2 To Ws.Range("A" & Rows.Count).End(xlUp).Row
.AddItem Ws.Range("A" & J)
Next J
End With
0