Bonjour
Que manque t il a ce code pour qu'il fonctionne normalement
beug sur cette ligne avec message (Variable objet ou variable du bloc With non définie)
Je vous remercie pour votre aide
Set cell = f.Range("A:A").Find(TextBox1, TextBox2, lookat:=xlWhole)
Option Explicit
Dim f As Worksheet, cell As Range
Dim no_ligne&, n&, ln&, i&, j&, flag&
'Pour le bouton Créer
Private Sub CommandButton1_Click()
Set cell = f.Range("A:A").Find(TextBox1, TextBox2, lookat:=xlWhole)
If Not cell Is Nothing Then
MsgBox "L'adhérent " & TextBox1 & " existe déjà. Vous ne pouvez que la modifier."
Exit Sub
End If
If MsgBox("Confirmez-vous l’insertion de cet adhérent ?", vbYesNo, "Demande de confirmation d’ajout") = vbYes Then
ln = f.Range("a65536").End(xlUp).Row + 1 'Pour placer le nouvel enregistrement à la première ligne de tableau non vide
For j = 1 To 50
Select Case j
Case 1, 2, 4 To 6, 8 To 12, 15 To 28, 41 To 45, 49
f.Cells(ln, j) = Controls("TextBox" & j).Value
Case 3, 7, 39, 40, 50
f.Cells(ln, j) = Controls("ComboBox" & j).Value
Case 13, 14, 29 To 38, 46, 47
f.Cells(ln, j) = Controls("CheckBox" & j).Value
End Select
Next j
f.Range(f.Cells(3, 1), f.Cells(f.Range("A" & Rows.Count).End(xlUp).Row, f.Cells(2, Columns.Count).End(xlToLeft).Column)).Sort _
key1:=f.Range("A3"), order1:=xlAscending, Header:=xlNo
Else
Exit Sub
End If
MsgBox "L'adhérent''" & TextBox1 & " a été créée."
Unload Me
UserForm1.Show
End Sub