• Initiateur de la discussion Initiateur de la discussion apdf1
  • Date de début Date de début

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

apdf1

XLDnaute Impliqué
Bonjour,

Je recherche comment mettre la 9éme colonne de ma listbox en "€"


Code:
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
     Dim ListIndex As Integer
  
     For ListIndex = 0 To (ListBox1.ListCount - 1)
        If ListBox1.Selected(ListIndex) = True Then
                Me.TextBox1 = Me.ListBox1.List(ListIndex, 0) ' N° Cde
                Me.TextBox4 = Me.ListBox1.List(ListIndex, 1) ' Nom
                Me.TextBox2 = Me.ListBox1.List(ListIndex, 3) ' Date
                Me.TextBox7 = Me.ListBox1.List(ListIndex, 2) ' Prénom
                Me.TextBox3 = Me.ListBox1.List(ListIndex, 4) ' Adresse
                Me.TextBox5 = Format(Me.ListBox1.List(ListIndex, 5), "00000") ' CP
                Me.TextBox8 = Me.ListBox1.List(ListIndex, 6) ' Ville
                Me.TextBox6 = Me.ListBox1.List(ListIndex, 7) ' Tél
                Me.TextBox10 = Format(Me.ListBox1.List(ListIndex, 8), "# ##,00€") 'Montant
                Me.TextBox9 = Me.ListBox1.List(ListIndex, 15) 'Date de Réglement
            Exit Sub
        End If

Merci d'avance

Cordialement
Max
 
Re : Format €uros

Re,

Voila le code au complet ! comment j'ajoute?

Code:
Dim Peut As Boolean 'pour éviter des appels de macro intempestifs (laisser ici)

'Quitter
Private Sub BtnQuitter_Click()
Unload Me
End Sub


Private Sub UserForm_Initialize()
 Dim aa As Variant
    aa = Feuil1.Range("A9:M" & Feuil1.Range("A65536").End(xlUp).Row)
        ListBox1.List = aa


  Dim n As Byte
  For n = 65 To 90
    ComboBox1.AddItem Chr(n) 'caractère dont le code ASCII est une lettre majuscule
  Next
  Peut = True 'libère le changement
  ComboBox1.SetFocus
End Sub


Private Sub Combobox1_Change()
  If Peut = False Then Exit Sub
  Peut = False 'empêche le changement
  ListBox1.Clear
  For Each cel In Sheets("Récap").Range("W:W").SpecialCells(xlCellTypeConstants)
    If UCase(Left(cel.Value, 1)) = ComboBox1 Then
      ListBox1.AddItem (cel.Value)
      For C = 0 To 10
        ListBox1.List(ListBox1.ListCount - 1, C) = Sheets("Récap").Cells(cel.Row, C + 1)
      Next
    End If
  Next
  If ListBox1.ListCount = 0 Then MsgBox "Aucun élément trouvé sur la feuille", vbInformation, "Attention,"
  ComboBox1 = ""
  Peut = True 'libère le changement
End Sub

Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
     Dim ListIndex As Integer
  
     For ListIndex = 0 To (ListBox1.ListCount - 1)
        If ListBox1.Selected(ListIndex) = True Then
                 Me.TextBox1 = Me.ListBox1.List(ListIndex, 0) ' N° Cde
                 Me.TextBox4 = Me.ListBox1.List(ListIndex, 1) ' Nom
                 Me.TextBox2 = Me.ListBox1.List(ListIndex, 3) ' Date
                 Me.TextBox7 = Me.ListBox1.List(ListIndex, 2) ' Prénom
                 Me.TextBox3 = Me.ListBox1.List(ListIndex, 4) ' Adresse
                 Me.TextBox5 = Format(Me.ListBox1.List(ListIndex, 5), "00000") ' CP
                 Me.TextBox8 = Me.ListBox1.List(ListIndex, 6) ' Ville
                 Me.TextBox6 = Me.ListBox1.List(ListIndex, 7) ' Tél
                 Me.TextBox10 = Format(Me.ListBox1.List(ListIndex, 8), "#, ##0.00€") 'Montant
               
                ' Me.TextBox9 = Me.ListBox1.List(ListIndex, 15) 'Date de Réglement
            Exit Sub
        End If
'MsgBox ListBox1.ListIndex + 9

End Sub

Max
 
Re : Format €uros

Re,

via la méthode "AddItem"

Code:
ListBox1.AddItem Format(cel.Value,"#,##0.00 $")
      For C = 0 To 10
        ListBox1.List(ListBox1.ListCount - 1, C) = Format(Sheets("Récap").Cells(cel.Row, C + 1), "#,##0.00 $")
      Next

j'ai pas tout regardé, mais sans doute adapter également lors de l'événement "Initialize" de l'usfd
 
Re : Format €uros

Re,

pour l'initialisation de l'usf, il faut également passer par "additem" ou bien alimentation par "list" et boucle tout de suite après, comme dans l'exembple ci-dessous sur listbox à 2 colonnes...
Code:
Private Sub UserForm_Initialize()
Dim i As Integer
With ListBox1
    .ColumnCount = 2
    .List = Range("A1:B9").Value
    For i = 0 To .ListCount - 1
        .List(i, 0) = Format(.List(i, 0), "#,##0.00 €")
    Next i
End With
End Sub
 
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD

Discussions similaires

E
  • Résolu(e)
Réponses
4
Affichages
828
Réponses
7
Affichages
1 K
M
Réponses
3
Affichages
2 K
MONADESIGN82
M
S
  • Résolu(e)
Réponses
9
Affichages
2 K
sgangbadjo
S
K
  • Question Question
Réponses
13
Affichages
1 K
S
  • Résolu(e)
Réponses
7
Affichages
1 K
sgangbadjo
S
P
Réponses
16
Affichages
2 K
patrick60880
P
H
Réponses
19
Affichages
7 K
N
Réponses
0
Affichages
654
nada bahri
N
A
Réponses
2
Affichages
1 K
A
Retour