formulaire de saisie, combobox fonctionne pas

jardibot

XLDnaute Junior
Bonjour,

Dans mon formulaire de saisie (il y a 33 textbox, des labels, un combobox, deux frames avec des optionbutton). Je n'ai pas renommé les textbox ni combobox). J'ai un bouton 'Modifier', et "Ajouter contact" et Quitter.


Mon 'combobox1' (le seul que j'ai), ne fonctionne pas.

Pourriez-vous m'aidez à trouver l'erreur?

De plus, lors de la saisie des optionbutton, il y a une erreur aussi… que je ne trouve pas. Merci de m'aidez

Code:
Option Explicit
Dim Ws As Worksheet
Private Sub UserForm1_Initialize()
Dim J As Long
Dim I As Integer

  Set Ws = Sheets("FICHE_INSCRIPTION") '
  With Me.ComboBox1
    For J = 2 To Ws.Range("C" & Rows.Count).End(xlUp).Row
      .AddItem Ws.Range("C" & J)
    Next J
  End With
  For I = 1 To 33
    Me.Controls("TextBox" & I).Visible = True 'affiche les données dans les textbox
Next I
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
  For I = 1 To 33
    Me.Controls("TextBox" & I) = Ws.Cells(Ligne, I + 2)
  Next I
 End Sub
Private Sub BT_MODIFIER_Click()
Dim Ligne As Long
Dim I As Integer
If MsgBox("Etes-vous certain de vouloir modifier ce produit ?", vbYesNo, "Demande de confirmation") = vbYes Then

  If Me.ComboBox1.ListIndex = -1 Then Exit Sub
  Ligne = Me.ComboBox1.ListIndex + 2
  For I = 1 To 33
    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 BT_QUITTER_Click()
Unload UserForm1
End Sub

Private Sub BT_AJOUTER_CONTACT_Click()
Dim L As Integer, lieu_inscription As String, civilite As String

If MsgBox("Etes-vous certain de vouloir INSERER ce nouveau contact ?", vbYesNo, "Demande de confirmation") = vbYes Then
L = Sheets("FICHE_INSCRIPTION").Range("a65536").End(xlUp).Row + 1 'Permet de se positionner sur la dernière ligne de tableau NON VIDE

'Choix lieu et civilite
For Each bouton_lieu_inscription In Frame_lieu_inscription.Controls
    If bouton_lieu_inscription.Value Then
      lieu_inscription = bouton_lieu_inscription.Caption
    End If
Next
For Each bouton_civilite In Frame_civilite.Controls
    If bouton_civilite.Value Then
      civilite = bouton_civilite.Caption
    End If
Next


Range("A" & L).Value = lieu_inscription
Range("B" & L).Value = civilite
Range("C" & L).Value = ComboBox1
Range("D" & L).Value = TextBox1
Range("E" & L).Value = TextBox2
Range("F" & L).Value = TextBox3
Range("G" & L).Value = TextBox4
Range("H" & L).Value = TextBox5
Range("I" & L).Value = TextBox6
Range("J" & L).Value = TextBox7
Range("K" & L).Value = TextBox8
Range("L" & L).Value = TextBox9
Range("M" & L).Value = TextBox10
Range("N" & L).Value = TextBox11
Range("O" & L).Value = TextBox12
Range("P" & L).Value = TextBox13
Range("Q" & L).Value = TextBox14
Range("R" & L).Value = TextBox15
Range("S" & L).Value = TextBox16
Range("T" & L).Value = TextBox17
Range("U" & L).Value = TextBox18
Range("V" & L).Value = TextBox19
Range("W" & L).Value = TextBox20
Range("X" & L).Value = TextBox21
Range("Y" & L).Value = TextBox22
Range("Z" & L).Value = TextBox23
Range("AA" & L).Value = TextBox24
Range("AB" & L).Value = TextBox25
Range("AC" & L).Value = TextBox26
Range("AD" & L).Value = TextBox27
Range("AF" & L).Value = TextBox28
'Range("AE" & L).Value = TextBox_Description_Traitement
'Range("AG" & L).Value = TextBox_Vaccinations
Range("AH" & L).Value = TextBox29
'Range("AI" & L).Value = TextBox_Allergies
Range("AJ" & L).Value = TextBox30
'Range("AK" & L).Value = TextBox_Regime_Alimentaire
Range("AL" & L).Value = TextBox31
Range("AM" & L).Value = TextBox32
'Range("AN" & L).Value = TextBox_Droit_Image
'Range("AO" & L).Value = TextBox_Droit_Depart
Range("AP" & L).Value = TextBox33
End If

MsgBox ("Produit inséré dans fichier sélectionné") 'Vous informe que le présent contact est insérer dans votre tableau Excel.

Unload Me 'Ferme le formulaire
UserForm1.Show 'Ouvre le formulaire

'Après insertion, on remet les valeurs initiales
OptionButton1.Value = True

End Sub
 

Pièces jointes

  • SUPPORT_003.xlsm
    35 KB · Affichages: 105

Statistiques des forums

Discussions
312 104
Messages
2 085 346
Membres
102 868
dernier inscrit
JJV