Date Time Picker Calendar Controls Excel

How to use both the date and time picker and calendar tools in an Excel macro

Below is the complete VBA code to transfer data from the user-form to the Excel worksheet:

Private Sub CommandButton_Click()
‘we transfer the name to cell a2 from the user-form
[a2]=TextBox1.Text
‘date of joining is transferred from the user-form to cell b2
[b2]=DTPicker1.Value
‘the calendar value is transferred from the user-form to the text-box
TextBox2.Text=Calendar1.Value
‘Now the data is transferred from the text-box to the worksheet
[c2]=TextBox2.Text
‘difference in years calculated
[d2]=Calendar1.Year – DTPicker1.Year
End Sub

Date Time Picker & Calandar VBA Code
VBA Code

Further reading:
Excel – Date & Time Picker / Calendar Controls

2 thoughts on “Date Time Picker Calendar Controls Excel”

  1. Hi Sir,
    Thanks for this video. Its very useful in doing vba forms.
    I have one doubt in DateTime Picker. We could see only the Date, but how to get the Time. Example: A basic In-time Out-time Tracker for a employee using VBA Forms. I want data like Date, In-time and out-time and last the total time presented today.
    Kindly help on this and share the video

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.