Calendrier dans userform VBA
BONJOUR A TOUS
Je voudrais mettre un calendrier ( le mien n'est pas activer) ou mettre un Olkdate Contrôl dans ce formulaire afin d’éviter les erreurs de frappe dans les dates et qu'elles apparaissent sous forme de dates à la française jour/mois/année dans mon tableau car seul "vrai ou faux" s’inscrivent en colonne "C",
et en colonne "B" le trimestre
merci
Bonjour,
J'ai ajouté une déclaration au haut du module "active_formulaire_compta" > et ajouté aussi le formulaire Calendrier ...
Clique sur le mini calendrier à droite du textbox > choisir une date > cliquer sur le bouton OK > la date va s'inscrire dans le textbox ...
ric
j’ai fait l'essai merci pour le calendrier ça marche mais j'ai toujours le problème de transmission dans mon tableau la date devient " vrai ou faux" et pas une date
merci si t'as une solution
Bonjour,
Un ligne à modifier ...
'*******************************************************************
'saisie dans compta par mois
'*****************************************************************
Private Sub boutonsaisie_Click()
Sheets("Compta par mois").Activate
Range("C5").Select
'Range("C5") = CDate(Textcomptadate1)
Selection.End(xlDown).Select
Selection.Offset(1, 0).Select
ActiveCell = CDate(Textcomptadate1) ' << ligne modifiée ...
ActiveCell.Offset(0, 1).Value = CBoxcomptadésigation2
ActiveCell.Offset(0, 2).Value = CBoxcomptamouvement3
ActiveCell.Offset(0, 3).Value = Textcomptadépense4
ActiveCell.Offset(0, 4).Value = Textcomptatva5
ActiveCell.Offset(0, 5).Value = Textcomptadépot6
ActiveCell.Offset(0, 6).Value = Textcomptadébit7
ActiveCell.Offset(0, 7).Value = Textcomptacommentaire8
ActiveCell.Offset(0, 8).Value = Cboxcomptapointé9
End Sub
ric
Bonjour,
Un autre code qui fait la même chose ...
'*******************************************************************
'saisie dans compta par mois
'*****************************************************************
Private Sub boutonsaisie_Click()
Dim MyNewRow As Integer
Worksheets("Compta par mois").Activate
Range("A5").Select
Selection.ListObject.ListRows.Add AlwaysInsert:=True
MyNewRow = Selection.ListObject.ListColumns(1).Range.Rows.Count - 1
Selection.ListObject.DataBodyRange(MyNewRow, 3) = CDate(Textcomptadate1)
Selection.ListObject.DataBodyRange(MyNewRow, 4) = CBoxcomptadésigation2
Selection.ListObject.DataBodyRange(MyNewRow, 5) = CBoxcomptamouvement3
Selection.ListObject.DataBodyRange(MyNewRow, 6) = Textcomptadépense4
Selection.ListObject.DataBodyRange(MyNewRow, 7) = Textcomptatva5
Selection.ListObject.DataBodyRange(MyNewRow, 8) = Textcomptadépot6
Selection.ListObject.DataBodyRange(MyNewRow, 9) = Textcomptadébit7
Selection.ListObject.DataBodyRange(MyNewRow, 11) = Textcomptacommentaire8
Selection.ListObject.DataBodyRange(MyNewRow, 10) = Cboxcomptapointé9
End Sub
ric
bonjour
je me suis permis d'ajouter ma méthode ShowX pour le calendrier et le placement a gauche du control injecté en parametre
on remplace donc l'appel cidessous
on remplace doncPrivate Sub Image1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Calendrier.Show
End Sub 'on élimine
par
Private Sub Image1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
With Calendrier: .ShowX Textcomptadate1: End With
End Sub 'on élimine
on ajoute une variable object dans le calendrier "en public juste en dessous de option explicit
Option Explicit
Public Obj As Object
et on ajoute ma fonction ShowX dans le calendrier
Public Function ShowX(Obj)
Set Calendrier.Obj = Obj
Calendrier.Show
End Function
et enfin on ajoute ma sub de placement qui prendra en charge toutes les conditions possibles d'apparenté du textbox injecté en paramètre dans ShowX
'***********************************************************
'ajout du placement au niveau de l'appelant
'fonction ecrite par patricktoulon sur exceldownload
Private Sub placementUF(Obj As Object)
If Not Obj Is Nothing Then
Dim Lft As Double, Rgt As Double, top As Double, Bot As Double, P As Object, PInsWidth As Double, PInsHeight As Double
Dim K As Double, Zom As Double, Ombre As Double, EcX As Double, OpWin As Long
OpWin = Int(Val(Mid(Application.OperatingSystem, InStrRev(Application.OperatingSystem, " ") + 1))) 'number version system
If OpWin = 6 Or Int(Val(Application.Version)) < 15 Then EcX = 2: Ombre = 2 Else EcX = 0: Ombre = 0 'ecart cadre
Lft = Obj.Left: top = Obj.top: Set P = Obj.Parent ' Normalement Page, Frame ou UserForm
Do
PInsWidth = P.InsideWidth: PInsHeight = P.InsideHeight ' Le Page en est pourvu, mais pas le Multipage.
If TypeOf P Is MSForms.Page Then Set P = P.Parent ' Prend le Multipage, car le Page est sans positionnement.
K = (P.Width - PInsWidth) / 2: Lft = (Lft + P.Left + K): top = (top + P.top + P.Height - K - PInsHeight)
If Not (TypeOf P Is MSForms.Frame Or TypeOf P Is MSForms.MultiPage) Then Exit Do
Set P = P.Parent
Loop
Me.Left = Lft + EcX + Ombre + ((Obj.Width / 2) * 2) ' a gauche en top
Me.top = top + 2 + Ombre + ((Obj.Height / 2) * 0)
End If
End Sub
et voila au click sur l'icon calendrier le calendrier s'affichera a droite du textbox ou que le userform soit
merci à vous deux de votre aide
profiter bien de votre confinement et prenez soin de vous