XL 2010 recherche intuitive et supprimer la saisie

arvin

XLDnaute Occasionnel
bonjour à tous

grâce à tous le collaborateurs , trop forts !, je peux faire une recherche intuitive dans le tableau suivant (cf userform)
ce que je voudrais c'est
1. supprimer le nom trouver
2. et/ou alors me positionner dans le tableau et nom indiqué

pouvez vous m'aider ?

spéciale dédicace à Mr BOISGONTIER pour son travail
 

Pièces jointes

  • IntuitifForm v1.xls
    63 KB · Affichages: 6

BOISGONTIER

XLDnaute Barbatruc
Repose en paix
Bonjour,

Code:
Dim f, rng, choix1()

Private Sub UserForm_Initialize()
  Set f = Sheets(1)
  Set rng = f.Range("A1:A" & f.[A65000].End(xlUp).Row)
  choix1 = Application.Transpose(rng)
  Me.ComboBox1.List = choix1
End Sub

Private Sub ComboBox1_Change()
 If Me.ComboBox1.ListIndex = -1 And IsError(Application.Match(Me.ComboBox1, choix1, 0)) Then
   Me.ComboBox1.List = Filter(choix1, Me.ComboBox1.Text, True, vbTextCompare)
   Me.ComboBox1.DropDown
   Me.TextBox2 = ""
  Else
    Position = Application.Match(Me.ComboBox1, rng, 0)
    Me.TextBox2 = rng.Cells(Position, 1)
    Me.TextBox3 = rng.Cells(Position, 1).Offset(, 1)
    f.Cells(Position, 1).Select
  End If
End Sub

Private Sub btnsupprimer_Click()
'procédure permettant de supprimer un enregistrement
 If Me.ComboBox1 = "" Then
    MsgBox "Il faut choisir un nom"
  Else
    If MsgBox("Voulez vraiment supprimer cet enregistrement ? " & Me.ComboBox1, vbCritical + vbYesNo + vbDefaultbtnsupprimer, "Suppression") <> vbYes Then Exit Sub
    Position = Application.Match(Me.ComboBox1, rng, 0)
    f.Cells(Position, 1).Resize(, 3).Delete
    UserForm_Initialize
  End If
End Sub

Boisgontier
 

Pièces jointes

  • Copie de IntuitifForm v1.xls
    66 KB · Affichages: 13
Dernière édition:

Discussions similaires

Statistiques des forums

Discussions
312 196
Messages
2 086 094
Membres
103 116
dernier inscrit
kutobi87