Erreur sur formulaire excel
jdcoro
Messages postés
2
Date d'inscription
Statut
Membre
Dernière intervention
-
michel_m Messages postés 16602 Date d'inscription Statut Contributeur Dernière intervention -
michel_m Messages postés 16602 Date d'inscription Statut Contributeur Dernière intervention -
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
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:
- Erreur sur formulaire excel
- Whatsapp formulaire opposition - Guide
- Liste déroulante excel - Guide
- Formulaire de réclamation facebook - Guide
- Word et excel gratuit - Guide
- Comment trier par ordre alphabétique sur excel - Guide
2 réponses
Pourquoi écrire
" A " au lieu de "A"
idem pour tout les codes de l'userform
pour i,itialize
" 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
L'erreur se produit sur la troisième ligne :
"Public Sub UserForm_Initialize() "
Merci pour ton aide