je n'arrive pas à trouver d'où vient l'erreur dans ma programmation. Pourriez vous m'aider à résoudre ce problème ?
Merci d'avance !!
Option Explicit
Dim Ws As Worksheet
Private Sub UserForm_Initialize()
'Pour le formulaire
Dim Q As Long
Dim P As Range
ComboBox1.ColumnCount = 3 'Pour la liste déroulante AIDE
ComboBox1.List() = Array("matériel", "financier", "humain")
Set Ws = Sheets("Suivi") 'Correspond au nom de votre onglet dans le fichier Excel
With Me.ComboBox2
For Q = 4 To Ws.Range("A" & Rows.Count).End(xlUp).Row
.AddItem Ws.Range("A" & Q)
Next Q
End With
For P = 1 To 16
Me.Controls("TextBox" & P).Visible = True
Next P
End Sub
'Pour la liste déroulante DEMANDE
Private Sub ComboBox2_Change()
Dim Ligne As Long
Dim P As Range
If Me.ComboBox1.ListIndex = -3 Then Exit Sub
Ligne = Me.ComboBox2.ListIndex + 4
ComboBox2.List() = Array("en cours", "validée", "/")
ComboBox2 = Ws.Cells(Ligne, "D")
For P = 1 To 16
Me.Controls("TextBox" & P) = Ws.Cells(Ligne, P + 4)
Next P
End Sub
'Pour la liste déroulante PROPOSITION
Private Sub ComboBox3_Change()
Dim Ligne As Long
Dim P As Range
If Me.ComboBox3.ListIndex = -5 Then Exit Sub
Ligne = Me.ComboBox3.ListIndex + 2
ComboBox3.List() = Array("en cours", "validée", "/")
ComboBox3 = Ws.Cells(Ligne, "E")
Ligne = Me.ComboBox3.ListIndex + 5
For P = 1 To 16
Me.Controls("TextBox" & P) = Ws.Cells(Ligne, P + 5)
Next P
End Sub
'Pour le bouton NOUVELLE ENTREE
Private Sub CommandButton1_Click()
Dim S As Range
If MsgBox("Confirmer l'ajout de cette nouvelle entrée?", vbYesNo, "Demande de confirmation d'ajout") = vbYes Then
S = Sheets("Suivi").Range("a65536").End(xlUp).Row + 1 'Pour placer le nouvel enregistrement à la premère de tableau non vide
Range("A" & S).Value = TextBox1
Range("B" & S).Value = TextBox2
Range("C" & S).Value = ComboBox1
Range("D" & S).Value = ComboBox2
Range("E" & S).Value = ComboBox3
Range("F" & S).Value = TextBox3
Range("G" & S).Value = TextBox4
Range("H" & S).Value = TextBox5
Range("I" & S).Value = TextBox6
Range("J" & S).Value = TextBox7
Range("K" & S).Value = TextBox8
Range("L" & S).Value = TextBox9
Range("M" & S).Value = TextBox10
Range("N" & S).Value = TextBox11
Range("O" & S).Value = TextBox12
Range("P" & S).Value = TextBox13
End If
End Sub
'Pour le bouton MODIFIER
Private Sub CommandButton2_Click()
Dim Ligne As Long
Dim P As Range
If MsgBox("Confirmez vous la modification de ce contact?", vbYesNo, "Demande de confirmation de modification") = vbYes Then
If Me.ComboBox1.ListIndex = -1 Then Exit Sub
Ligne = Me.ComboBox1.ListIndex + 2
Ws.Cells("LignB") = ComboBox2
For P = 1 To 16
If Me.Controls("TextBox" & P).Visible = True Then
Ws.Cells(Ligne, P + 2) = Me.Controls("TextBox" & P)
End If
Next P
End If
End Sub
'Pour le bouton QUITTER
Private Sub CommandButton3_Click()
Unload Me
End Sub