XL 2016 Formater colonne listbox

KTM

XLDnaute Impliqué
Bonsoir chers tous
je voudrais présenter des données dans mon listbox.
Mais ma colonne 3 affiche les chiffres dans un format diffèrent de ma base .
les nombres de ma colonne 3 doivent être à deux chiffres (00 - 11- 01-02-06 ........) comme dans ma base.
Merci.
 

Pièces jointes

  • lBOX.xlsm
    18.7 KB · Affichages: 13

job75

XLDnaute Barbatruc
La propriété RowSource peut aussi être utilisée :
Code:
Private Sub UserForm_Initialize()
    Set tbl = Range("A4:C11")
    ListBox1.ColumnHeads = True
    ListBox1.RowSource = tbl.Address(External:=True)
End Sub
Mais perso je préfère utiliser la méthode List.
 

ChTi160

XLDnaute Barbatruc
Bonsoir KTM
Peut-être avec un truc du genre Lol
Pas sûr d'avoir compris !
les nombres de ma colonne 3 doivent être à deux chiffres (00 - 11- 01-02-06 ........)
VB:
Option Explicit
Option Compare Text
Dim tbl
Dim Lgn As Long
Dim Col As Byte
Private Sub UserForm_Initialize()
        tbl = Range("A4:c11").Value
      With Me.ListBox1
        For Lgn = 1 To UBound(tbl, 1)
             .AddItem tbl(Lgn, 1)
          For Col = 2 To UBound(tbl, 2)
             .List(.ListCount - 1, Col - 1) = IIf(Col = 2, Format(tbl(Lgn, Col), "00"), tbl(Lgn, Col))
          Next Col
        Next Lgn
      End With
End Sub
bonne fin de Soirée
jean marie
 

KTM

XLDnaute Impliqué
Bonsoir KTM
Peut-être avec un truc du genre Lol
Pas sûr d'avoir compris !

VB:
Option Explicit
Option Compare Text
Dim tbl
Dim Lgn As Long
Dim Col As Byte
Private Sub UserForm_Initialize()
        tbl = Range("A4:c11").Value
      With Me.ListBox1
        For Lgn = 1 To UBound(tbl, 1)
             .AddItem tbl(Lgn, 1)
          For Col = 2 To UBound(tbl, 2)
             .List(.ListCount - 1, Col - 1) = IIf(Col = 2, Format(tbl(Lgn, Col), "00"), tbl(Lgn, Col))
          Next Col
        Next Lgn
      End With
End Sub
bonne fin de Soirée
jean marie
Merci infiniment
 

Discussions similaires

Réponses
25
Affichages
603

Statistiques des forums

Discussions
311 721
Messages
2 081 929
Membres
101 843
dernier inscrit
Thaly