tableau & listbox adapté

  • Initiateur de la discussion lostgen67
  • Date de début
L

lostgen67

Guest
Bonjour le forum....

Voila j'ai réussi à adapter les largeurs de colonnes de listbox automatiquement a celle de mon tableau ou se trouver un autofit.

Il ya peut etre mieux mais j'ai po trouvé :unsure:

voila donc pour ceux que cela intéresse....

Private Sub inilb2()
Dim mafeuille As String
Dim Plage As String
Application.ScreenUpdating = False
mafeuille = USFVISU.ComboBox1.Text
ListBox2.RowSource = ''
Worksheets(mafeuille).Select
Plage = Sheets(mafeuille).Range('a2:m2').Address
ListBox2.RowSource = Plage
Dim c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13 As Integer
Dim vcol As Integer
vcol = 4 ' partie a poffiner
c1 = 0
c2 = 0
c3 = Round((Sheets(mafeuille).Range('c1').ColumnWidth) * vcol, 0)
c4 = Round((Sheets(mafeuille).Range('d1').ColumnWidth) * vcol, 0)
c5 = Round((Sheets(mafeuille).Range('e1').ColumnWidth) * vcol, 0)
c6 = Round((Sheets(mafeuille).Range('f1').ColumnWidth) * vcol, 0)
c7 = Round((Sheets(mafeuille).Range('g1').ColumnWidth) * vcol, 0)
c8 = Round((Sheets(mafeuille).Range('h1').ColumnWidth) * vcol, 0)
c9 = Round((Sheets(mafeuille).Range('i1').ColumnWidth) * vcol, 0)
c10 = Round((Sheets(mafeuille).Range('j1').ColumnWidth) * vcol, 0)
c11 = Round((Sheets(mafeuille).Range('k1').ColumnWidth) * vcol, 0)
c12 = Round((Sheets(mafeuille).Range('l1').ColumnWidth) * vcol, 0)
c13 = Round((Sheets(mafeuille).Range('m1').ColumnWidth) * vcol, 0)
With ListBox2
.ColumnCount = 13
.ColumnWidths = c1 & ';' & c2 & ';' & c3 & ';' & c4 & ';' _
& c5 & ';' & c6 & ';' & c7 & ';' & c8 & ';' & c9 & ';' & c10 & ';' & c11 & ';' & c12 & ';' & c13

End With
End Sub
 

Discussions similaires

Réponses
14
Affichages
696

Statistiques des forums

Discussions
314 073
Messages
2 105 361
Membres
109 339
dernier inscrit
Nature Sereine