report de date ne fonctionne pas

  • Initiateur de la discussion Initiateur de la discussion nrdz83
  • 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 !

nrdz83

XLDnaute Impliqué
Bonjour à tous

on a un programme au travail qui bug un petit peu mais on arrive pas à solutionner la saisie de la date dans notre feuille, tous se range sauf la date.

Le code utilisé est celui-ci.
Code:
Private Sub remplirbdd(£ligne1 As Long, £nomfeuille1 As String)

'Dim £Ctrl As Control
'Dim £coln As Long
With Sheets(£nomfeuille1)
For Each £Ctrl In Me.Controls
    If TypeName(£Ctrl) = "ComboBox" Or TypeName(£Ctrl) = "TextBox" Then
    £coln = Val(Replace(£Ctrl.Name, TypeName(£Ctrl), ""))
                .Cells(£ligne1, £coln) = £Ctrl.Value
   End If
   If TypeName(£Ctrl) = "DTPicker" Then
        £coln = Val(Replace(£Ctrl.Name, TypeName(£Ctrl), ""))
        
        .Cells(£ligne1, £coln) = Format(£Ctrl.Value, "dd/mm/yyyy")
        
        
   End If
   
Next £Ctrl
End With
End Sub

On est passé à excel 2010 ça ne pourrait pas venir de ça ?

Ce code est il correct car avec les sigles £ pour ma part je n'y comprend rien.

Par avance merci pour vos lumières amitiés
 
Re : report de date ne fonctionne pas

Bonjour,

regarde du coté de la fonction "cdate", devrait répondre à ta question, exemple ci-dessous pour renvoyer une date dans une cellule à partir d'un "textbox" :
Code:
Range("A1").Value = CDate(textbox1.Value)
bon après midi
@+
 
Re : report de date ne fonctionne pas

Oui j'ai bien regardais envoyer un exemple du classeur pas possible il est trop lourd,
le code bu bouton valider
Code:
Private Sub CmdValider_Click()
If TextBox11.Value = "" Then Exit Sub
If ComboBox5.ListIndex = -1 Then Exit Sub
If Not IsNumeric(TextBox11.Value) Then
    Call MsgBox("Vous devez inscrire une valeur numérique", vbInformation, Application.Name)
    FrmArticle.SetFocus
    TextBox11.Value = ""
    TextBox11.SetFocus
    Exit Sub
End If

If OptionButton2 = True Then
    If Val(TextBox11.Value) > Val(Label18.Caption) Then
        Call MsgBox("Stock insuffisant", vbInformation, Application.Name)
    Exit Sub
    End If
End If

dl1 = Sheets(nomfeuille1).Range("b65536").End(xlUp).Row + 1
Call remplirbdd(£ligne1:=dl1, £nomfeuille1:=nomfeuille1)
'lig = CLng(ComboBox5.List(ComboBox5.ListIndex, ComboBox5.ColumnCount - 1))
With Sheets(nomfeuille3)
If OptionButton1 = True Then
' passage de la colonne b en c
    .Range(colqte & lig1) = Val(.Range(colqte & lig1)) + Val(TextBox11.Value)
Else
    .Range(colqte & lig1) = Val(.Range(colqte & lig1)) - Val(TextBox11.Value)
End If
End With
Call raz
Label18.Caption = ""
End Sub

le code d'initialisation de l'userform
Code:
Private Sub UserForm_Initialize()

Application.EnableEvents = False
nomfeuille1 = "Mouvement"
nomfeuille2 = "Article"
nomfeuille3 = "STOCK EN COURS"
col = "a"
colqte = "c"
With ComboBox5
    .Clear
    .ColumnCount = 3
    .ColumnWidths = "80;60;0"
    .Style = fmStyleDropDownList '
    .BoundColumn = 1 ' combobox1.text contient le nom
    For Each cellule In Sheets(nomfeuille2).Range("a4:a" & Sheets(nomfeuille2).Range(col & "65536").End(xlUp).Row)
            .AddItem cellule.Value
            .List(.ListCount - 1, 1) = cellule.Offset(0, 1).Value
            .List(.ListCount - 1, .ColumnCount - 1) = cellule.Row
        
    Next cellule
End With
DTPicker3.Value = Now
Call affiche(False)
OptionButton1.Value = True
End Sub

le code pour la date
Code:
Private Sub remplirbdd(£ligne1 As Long, £nomfeuille1 As String)

'Dim £Ctrl As Control
'Dim £coln As Long
With Sheets(£nomfeuille1)
For Each £Ctrl In Me.Controls
    If TypeName(£Ctrl) = "ComboBox" Or TypeName(£Ctrl) = "TextBox" Then
    £coln = Val(Replace(£Ctrl.Name, TypeName(£Ctrl), ""))
                .Cells(£ligne1, £coln) = £Ctrl.Value
   End If
   If TypeName(£Ctrl) = "DTPicker" Then
        £coln = Val(Replace(£Ctrl.Name, TypeName(£Ctrl), ""))
        
        .Cells(£ligne1, £coln) = CDate(DTPicker3.Value)
        
        '.Cells(£ligne1, £coln) = Format(£Ctrl.Value, "dd/mm/yyyy")
        
        
        

        
   End If
   
Next £Ctrl
End With
End Sub

merci d'avance
 
Re : report de date ne fonctionne pas

Re,

le code ci-dessous fonctionne chez moi :
Code:
Option Explicit
Private Sub UserForm_Click()
test
End Sub
Private Sub test()
Dim £Ctrl As Control
Dim £coln As Long, £ligne1 As Long
£ligne1 = 4
With ActiveSheet
For Each £Ctrl In Me.Controls
    If TypeName(£Ctrl) = "ComboBox" Or TypeName(£Ctrl) = "TextBox" Then
    £coln = Val(Replace(£Ctrl.Name, TypeName(£Ctrl), ""))
                .Cells(£ligne1, £coln) = £Ctrl.Value
   End If
   If TypeName(£Ctrl) = "DTPicker" Then
        £coln = 2
        .Cells(£ligne1, £coln) = CDate(DTPicker1.Value)
   End If
Next £Ctrl
End With
End Sub

mais sous 2003 et forcement pas dans le même contexte....
 
- 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

Réponses
5
Affichages
237
Réponses
3
Affichages
298
  • Question Question
Microsoft 365 Problème de date
Réponses
5
Affichages
163
Réponses
4
Affichages
177
Réponses
10
Affichages
281
Retour