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

One thought on “Date Time Picker Calendar Controls Excel

  1. Pingback: Date Time Picker Tool on User Form | Excel VBA Training Videos

Leave a Reply

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