Insert date through DateTimePicker Class

YasserKhalil
PlatinumLounger
Posts: 4911
Joined: 31 Aug 2016, 09:02

Insert date through DateTimePicker Class

Post by YasserKhalil »

Hello everyone

In the attachment, I have got a class module named "DateTimePicker" that enables me to select a date on a userform through combobox and it is ok till this point. When trying to insert the date to active cell, I got blank result

Code: Select all

Private Sub CommandButton1_Click()
    ActiveCell.Value = Me.cmbDateStart.Value
End Sub
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Insert date through DateTimePicker Class

Post by HansV »

Use

ActiveCell.Value = dpFrom.Value(1)

to insert the start date, or

ActiveCell.Value = dpFrom.Value(2)

to insert the end date.
Best wishes,
Hans

YasserKhalil
PlatinumLounger
Posts: 4911
Joined: 31 Aug 2016, 09:02

Re: Insert date through DateTimePicker Class

Post by YasserKhalil »

Amazing. Thank you very much.
Is it possible to deal with such Class to insert date by double-click on a cell a way from userform?

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Insert date through DateTimePicker Class

Post by HansV »

Not that I know of.
Best wishes,
Hans