No cache version.

Caching disabled. Default setting for this page:enabled (code LNG204)
If the display is too slow, you can disable the user mode to view the cached version.

Vous devez être membre et vous identifier pour publier un article.
Les visiteurs peuvent toutefois commenter chaque article par une réponse.

Liste déroulante modifiable en VBA

Astuces de l’Infobrol (Développement)Article publié le 27/10/2005 10:11:20


Les contrôles



Nom de la ComboBox = Constructeur
Nom du CommandButton "Valider Choix" = OK
Nom du CommandButton "Annuler" = Annuler


Le code



Code lançant l'ouverture de la boîte de dialogue
  1. Sub AfficheListeDeroulanteModifiable()
  2. ListeDeroulanteModifiable.Show
  3. End Sub


Code d'initialisation du formulaire

  1. Private Sub UserForm_Initialize()
  2. Me.Constructeur.RowSource = "Feuil1!A1:A" & Sheets("Feuil1").Cells(1, 1).End(xlDown).Row
  3. End Sub


Code d'activation du formulaire

  1. Private Sub UserForm_Activate()
  2. Me.Constructeur.ListIndex = -1
  3. End Sub


Code des boutons

1 / Bouton OK
  1. Private Sub OK_Click()
  2. Me.Hide
  3. If Me.Constructeur.ListIndex = -1 Then
  4. Sheets("Feuil1").Cells(1, 1).End(xlDown).Offset(1, 0).Value = Me.Constructeur.Value
  5. ' Tri de la plage de données suite à l'ajout d'un élément
  6. Sheets("Feuil1").Range([A1], [A1].End(xlDown)).Select
  7. Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _
  8. OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
  9. Else
  10. End If
  11. ' Mise en place de la valeur choisie en D2
  12. Sheets("Feuil1").Cells(2, 4).Value = Me.Constructeur.Value
  13. End Sub

2 / Bouton Annuler
  1. Private Sub Annuler_Click()
  2. ListeDeroulanteModifiable.Hide
  3. End Sub




Avatar :: sysprep Un article de sysprep

Source : ericrenaud.free.fr


Sélection, tri et recherche d'articles
FILTRER :
TRIER :1er critère : 2e critère :
CHERCHER : Dans les titres Dans le contenu


[Afficher les liens en fonction des critères du formulaire ci-dessus]

English translation

You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.

If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.

Thank you in advance.

Document created the 13/09/2004, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/ast-rf-251.html

The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.