Format date listbox

abtony

XLDnaute Impliqué
Bonjour a tous,

comment définir le format date dans ce code en colonne 3

VB:
 Private Sub Label15_Click()
Dim tableau() As Variant
    Dim i As Integer
    Dim j As Byte
    Dim wsa As Worksheet
    Dim ligne
    Dim n As Byte
    Set wsa = ThisWorkbook.Worksheets("Imprim")
    If OptionButton1.Value = False And OptionButton2.Value = False And OptionButton3 = False Then
        MsgBox "Sélectionner format date ou client", vbExclamation, G
        OptionButton1.SetFocus
        Exit Sub
    End If
    
    Application.ScreenUpdating = False
    'Workbooks.Add 'création d'un nouveau classeur temporaire
    'wsa.Cells("A2").Select
    wsa.Range("A3:I65000").Clear
    tableau() = ListBox1.List
    j = ListBox1.ColumnCount
    i = ListBox1.ListCount + 2
    wsa.Range("A3:" & Cells(i, j).Address) = tableau()
    
    wsa.Cells(ligne, 3).Value = CDbl(Val(ListBox1.List(i, 3))) ' j'essaye sur cette ligne mais sans succès.
    
    
wsa.Range("B1").Value = GestAchats.Caption
Dim x As Integer, L As Integer, nombre_de_colonne As Integer
 
  nombre_de_colonne = 9
  For x = 5 To nombre_de_colonne
    L = wsa.Cells(Rows.Count, x).End(xlUp).Row
    wsa.Cells(L + 1, x).Formula = "=SUM(" & Cells(2, x).Address & ":" & Cells(L, x).Address & ")"
    wsa.Cells(L + 1, x).Interior.ColorIndex = 37
    wsa.Cells(L + 1, x).Font.Bold = True
  wsa.Range("A3:" & Cells(i, j).Address).EntireColumn.AutoFit
  Next
Application.ScreenUpdating = True
    On Error Resume Next
    'wsa.PrintOut 'impression
    'wsa.Range("A3:I65000").Clear
End Sub

Merci d'avance pour votre aide

Cordialement

Abtony
 

ChTi160

XLDnaute Barbatruc
Re : Format date listbox

Bonsoir abtony
Bonsoir le Fil
Bonsoir le forum
arff pas évident une fois encore , sans Fichier

[highLight=vba]wsa.Cells(ligne, 3).Value = Format(Cdate((ListBox1.List(i, 3)),"ddd dd mmmm yyyy")[/highLight]
cela devrait renvoyer une date sous la forme : Dim 09 Septembre 2012
Bonne fin de Journée
Amicalement
Jean marie
 

abtony

XLDnaute Impliqué
Re : Format date listbox

Bonsoir Modeste, ChTi160,

j'ai essayé la solution a ChTi160, mais il y a une erreur.

J'ai pu contourné le problème avec ce bout de code

Code:
wsa.Range("C:C").NumberFormat = "mm/dd/yyyy"

Le renvois de la listbox vers la feuille excel inverse le jour avec le mois, donc je re formate le format comme ci
dessus.

Merci infiniment pour vos réponses

Cordialement

Abtony

Edit:

Sur l'userform optionbutton pour choix et filtre

Ensuite combobox pour choix suivant et affichage sur listbox1

et imprimer (sur feuille imprim) impréssion désactivé

si des amélioration peuvent être apporté ca serais super Merci
 

Pièces jointes

  • essai filtre .xlsm
    73.4 KB · Affichages: 78
  • essai filtre .xlsm
    73.4 KB · Affichages: 85
  • essai filtre .xlsm
    73.4 KB · Affichages: 91
Dernière édition:

Discussions similaires

Réponses
17
Affichages
803

Statistiques des forums

Discussions
312 094
Messages
2 085 244
Membres
102 833
dernier inscrit
Hassna