Imbrication combobox + Modif Item

24besoinaide.xlsm (27.59 Ko)
24besoinaide.xlsm (27.59 Ko)

Bonjour,

Je suis entrain de créer une base de donnée. Mon problème est :

- Dans le premier bouton "choix nom" de mon fichier, j'aimerai que le combobox "Nom" soit alimenté suivant le choix du type.

-Dans le deuxième bouton, j'aimerai que suivant le choix "Type ou Nom", juste besoin de marquer dans le textBox le nom ou le type et ça se mets à jour directement

Si vous pouvez me trouver une solution pour pouvoir supprimer la colonne ou la cellule c'est avec plaisir.

j'espère que ce ne soit pas trop compliqué

Bonjour

Voila pour la ComboBox3

Dim Ws As Object

Private Sub UserForm_Initialize()
 Set Ws = Sheets("Four")
   ComboBox2.List = Application.Transpose(Ws.Range(Ws.Range("A1"), Ws.Cells(1, Columns.Count).End(xlToLeft)))
End Sub

Private Sub ComboBox2_Change()
Dim Col As String
   Select Case ComboBox2.ListIndex
      Case 0
         Col = "A"
      Case 1
         Col = "B"
      Case 2
         Col = "C"
      Case Else
         Exit Sub
   End Select
ComboBox3.Clear
   ComboBox3.List = Ws.Range(Col & "2:" & Col & Ws.Range(Col & Rows.Count).End(xlUp).Row).Value
End Sub

A+

Maurice

Merci de ta réponse. Ce code fonctionne si les colonnes sont figées. J'aimerais que ça prends en compte toutes les colonnes. C'est à dire, si je souhaite ajouter un nouveau type, ça me prends dans le code automatiquement.

Bonjour

voila la modife

Private Sub ComboBox2_Change()
Dim Col As Long
Dim L As Long
If ComboBox2.ListIndex = -1 Then Exit Sub
Col = ComboBox2.ListIndex + 1
   Derlg = Ws.Cells(Rows.Count, Col).End(xlUp).Row
ComboBox3.Clear
   For L = 2 To Derlg
      ComboBox3.AddItem Ws.Cells(L, Col).Value
   Next
End Sub

A+

Maurice

Merci de ta réponse. Ça fonctionne !

Déjà une question de résolu Me manque plus qu'une

Bonjour

hum on dirais un devoir

mes bon voila une réponse

Private Sub UserForm_Initialize()
   ComboBox1.List = Array("Type", "Nom")
   ComboBox2.Visible = False
End Sub

Private Sub ComboBox1_Change()
   If ComboBox1.Value = "Nom" Then
         ComboBox2.Visible = True
         ComboBox2.Clear
            With Sheets(Feuil2.Name)
               ComboBox2.List = Application.Transpose(.Range(.Range("A1"), .Cells(1, Columns.Count).End(xlToLeft)))
            End With
     Else
         ComboBox2.Visible = False
   End If
End Sub

Private Sub Button1_Click()

if TextBox1.Value = "" then exit sub

   With Sheets(Feuil2.Name)
      If ComboBox1.Value = "Type" Then
         Dercol = .Cells(1, Columns.Count).End(xlToLeft).Column + 1
         .Cells(1, Dercol).Value = TextBox1.Value
      Else
         Col = ComboBox2.ListIndex + 1
         DerLig = .Cells(Rows.Count, Col).End(xlUp).Row + 1
         .Cells(DerLig, Col).Value = TextBox1.Value
      End If
   End With
Unload Me
End Sub

A+

Maurice

Rechercher des sujets similaires à "imbrication combobox modif item"