Bonjour Chers tous,
J'ai un projet de création de formulaire pour la gestion de coopératives. J'ai utilisé le code ci-dessous mais quand je l'exécute j'ai le message d'erreur suivant "la méthode 'value' de l'objet 'Range' a échoué".
Etant novice en VBA, je sollicite votre aide.
Merci d'avance
'------------------------------------------------------------------------------------------
'PROCEDURE POUR AJOUTER UNE NOUVELLE COOPERATIVE
'------------------------------------------------------------------------------------------
Function Ajout_cooperative()
ThisWorkbook.Sheets("Cooperatives").Activate
Dim LastRow1 As Long, LastRow2 As Long
LastRow1 = ThisWorkbook.Sheets("Cooperatives").Cells(Rows.Count, "A").End(xlUp).Row
LastRow2 = LastRow1 + 1
With ThisWorkbook.Sheets("Cooperatives")
.Cells(LastRow2, "B").Value = FrmAjout_scoop.TextBox1.Value
.Cells(LastRow2, "C").Value = FrmAjout_scoop.TextBox2.Value
.Cells(LastRow2, "D").Value = FrmAjout_scoop.ComboBox6.Value
.Cells(LastRow2, "E").Value = FrmAjout_scoop.ComboBox1.Value
.Cells(LastRow2, "F").Value = FrmAjout_scoop.ComboBox2.Value
.Cells(LastRow2, "G").Value = FrmAjout_scoop.ComboBox4.Value
.Cells(LastRow2, "H").Value = FrmAjout_scoop.TextBox6.Value
.Cells(LastRow2, "I").Value = FrmAjout_scoop.TextBox6.Value
.Cells(LastRow2, "J").Value = FrmAjout_scoop.TextBox3.Value
.Cells(LastRow2, "K").Value = FrmAjout_scoop.TextBox4.Value
.Cells(LastRow2, "L").Value = FrmAjout_scoop.TextBox5.Value
.Cells(LastRow2, "M").Value = FrmAjout_scoop.ComboBox5.Value
.Cells(LastRow2, "N").Value = FrmAjout_scoop.TextBox7.Value
.Cells(LastRow2, "O").Value = FrmAjout_scoop.TextBox13.Value
.Cells(LastRow2, "P").Value = FrmAjout_scoop.TextBox12.Value
.Cells(LastRow2, "Q").Value = FrmAjout_scoop.TextBox11.Value
.Cells(LastRow2, "R").Value = FrmAjout_scoop.TextBox10.Value
.Cells(LastRow2, "S").Value = FrmAjout_scoop.TextBox9.Value
End With
Call reset_all_controls2
End Function
********************************************************************************
Function reset_all_controls2()
Dim ctl As MSForms.Control
For Each ctl In FrmAjout_scoop.Controls
Select Case TypeName(ctl)
Case "TextBox"
ctl.Text = ""
Case "CheckBox", "OptionButton", "ToggleButton"
ctl.Value = False
Case "ComboBox", "ListBox"
ctl.ListIndex = -1
End Select
Next ctl
End Function