1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
Private Sub UserForm_Initialize()
Dim Plg As Range
'par exemple sur feuille Feuil4
Set Plg = DefPlage(Worksheets("Feuil4"), 1, 1)
If Plg Is Nothing Then Exit Sub 'éventuellement un message !
ListBox1.ColumnCount = Plg.Columns.Count
ListBox1.RowSource = Plg.Address
End Sub
Function DefPlage(Fe As Worksheet, L As Long, C As Long) As Range
On Error GoTo Fin
With Fe
Set DefPlage = .Range(.Cells(L, C), _
.Cells(.Cells.Find("*", .[A1], -4123, , _
1, 2).Row, .Cells.Find("*", .[A1], -4123, , _
2, 2).Column))
End With
Exit Function
Fin:
Set DefPlage = Nothing
End Function |
Partager