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 36 37 38 39 40 41 42 43 44 45
|
Private Sub cmd_recherche_Click()
Dim monFichierAppli As String, monFichierSource As String, feuilleSource As String
Dim cpt_col As Integer, derColonne As Integer, nb_col As Integer
monFichierAppli = "AIDE.xls"
monFichierSource = UserForm1.TextBox_nom_fic
feuilleSource = Me.ComboBox_feuilles
derColonne = Workbooks(monFichierSource).Sheets(feuilleSource).Range("A1").End(xlToRight).Column
maListe = "ListBox1"
Controls(maListe).Clear
Controls(maListe).ColumnCount = derColonne 'Nbre de colonnes
'Controls(maListe).ColumnWidths = "120;10" 'Largeur de la colonne
'Mise en place des noms de colonne
For cpt_col = 1 To derColonne
nomColonne = Sheets(feuilleSource).Cells(1, cpt_col)
If cpt_col = 1 Then
Controls(maListe).AddItem nomColonne
Else
Controls(maListe).List(Controls(maListe).ListCount - 1, cpt_col) = nomColonne
End If
Next cpt_col
For cpt = 2 To Sheets(feuilleSource).Range("A" & Rows.Count).End(xlUp).Row
For cpt_col = 1 To derColonne
If cpt_col = 1 Then
Controls(maListe).AddItem Sheets(feuilleSource).Cells(cpt, cpt_col)
Else
Controls(maListe).List(Controls(maListe).ListCount - 1, cpt_col) = Sheets(feuilleSource).Cells(cpt, cpt_col)
End If
Next cpt_col
Next cpt
End Sub |
Partager