Private dou As Long, aou As Long Private Sub UserForm_Activate() Dim plage As Range, c As Range Set plage = Range("A1:A" & Range("B" & Rows.Count).End(xlUp).Row).SpecialCells(xlCellTypeConstants) With ListBox1 .ColumnCount = 2 .ColumnWidths = Cells(1.1).Width * 2 .Width = Cells(1, 1).Width For Each c In plage .AddItem c.Value .List(ListBox1.ListCount - 1, 1) = c.Row Next End With Set plage = Nothing With ListBox2 .ColumnCount = 2 .ColumnWidths = IIf(Range("B1").Width > Range("c1").Width, Range("B1").Width, Range("c1").Width) End With ListBox2.Width = Val(ListBox2.ColumnWidths) * 2 End Sub Private Sub ListBox1_Click() dou = ListBox1.List(ListBox1.ListIndex, 1) On Error Resume Next aou = Range("A" & dou + 1 & ":A" & Rows.Count).SpecialCells(xlCellTypeConstants).Row - 1 If Err > 0 Then aou = Range("B" & Rows.Count).End(xlUp).Row On Error GoTo 0 ListBox2.RowSource = "B" & dou & ":C" & aou End Sub Private Sub ListBox2_Click() ' Nous y voilà donc. ' je te laisse le choix entre deux comportements (mets en commentaires celui qui te plait moins ' et décommente l'autre '_______________________________________________________ 'TextBox1.Text = ListBox2.List(ListBox2.ListIndex, 0) '| ce choix remplit, mais sans lier, ce qui fait que tu devras 'TextBox2.Text = ListBox2.List(ListBox2.ListIndex, 1) '| ajouter du code si tu veux modifier les cellules correspondantes '_______________________________________________________| '________________________________________________________ TextBox1.ControlSource = "B" & dou + ListBox2.ListIndex '| ce choix me parait plus intelligent. Toute modif de l'une de ces TextBox2.ControlSource = "C" & dou + ListBox2.ListIndex '| deux textboxes modifiera à la fois les cellules et la listbox '________________________________________________________| sans autre code End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionPrivate Sub CommandButton1_Click() ComboBox1.RowSource = "C1:C3" End Sub
Private Sub commandbutton1_click() derlig = Range("B" & Rows.Count).End(xlUp).Row Dim plage As Range, c As Range Set plage = Range("B1:B" & derlig).SpecialCells(xlCellTypeBlanks).Offset(0, -1) Range("A:A").Insert shift:=xlShiftToRight For Each c In plage Range("A" & c.Row + 1).Value = c.Value Range("B" & c.Row).Value = "" Next plage.EntireRow.Delete End Sub
ucfoutu a dit:
dur dur, le lundi matin, au Maroc également, je vois ...
Effectivement ! Comme tout les lundis du monde !