If Application.International(xlDateOrder) = 0 Then ' 0 = month-day-year 1 = day-month-year 2 = year-month-day This Sub will be called in the UserForm Initialize Event procedure. This is the main procedure for creating the calendar for the Date Picker.Next, create a Private Sub called Create_Calender.These variables will be available in every Sub Procedure. Firstly, declare the variables you will be using in the full process under Option Explicit.In this step, you have to insert VBA codes into the UserForm. This is the most important step in creating a date picker. Keep your UserForm simple and easy to read.I have changed the background color of the Calendar Frame.Here, I have changed the Caption of the Farme1 to “Date Picker”.You can change the background color, text alignment, caption, font, etc. This step is just to make the UserForm look better. In this step, I will change the properties of the UserForm according to my choice. Step 03: Change Properties of the Date Picker UserForm Finally, the design of the UserForm is complete.Change the Captions, Font, and Alignment of Text according to the image below.Therefore, the UserForm will look like the image below.Change the Font, Font style, and Size to Calibri, Bold, and 12.Edit the Caption of the CheckBox as “Add Time”.Insert a CheckBox Control below the Calendar Frame.Change the Name of each CommandButton as C2, C3, C4, …….C42.As a result, a calendar-like interface has been created.Later, paste this set of CommandButtons for 5 more times.Next, select the 7 CommandButtons at a time and Copy this whole group.Then, copy the CommandButton 6 more times and paste them serially.Later, with the help of the VBA code the Caption will be added. Set the Name Option of the CommandButton as “C1” from the Properties Window.Next, add CommandButton Control inside the Calendar Frame.Set the Caption of the other 6 Labels as the Weekday’s short forms.Change the Caption of the first Label to “Sun” from the Properties Window.Follow the Image for a better understanding.At this point, copy the Label 6 times and place these identical Labels side by side.Set the BackColor of the Label as Highlight Text.Change the Font, Font style, and Size to Calibri, Bold, and 12 respectively.Click on the 3 dots beside the Font option marked in the Picture below.Delete the caption “Label1” in Properties Window and keep it blank.Insert one Label Control from the Toolbox inside the Calendar Frame.In this Frame, I will build the calendar with the help of Labels and CommandButtons.Afterward, add another Frame Control and change the caption to “Calendar”.Also change the Font, Font style, and Size just like the previous one.Change the Name of ComboBox to “Year_Box” from the Properties Window.This ComboBox will be used for the Year input.Now, following the same procedure, add another ComboBox beside the previous one.In this Month_Box, Month Names will be shown.Select Calibri Font, Font style as Bold, and Size as 12.Click on the marked 3 dots of the Font option in the Properties Window.Now, from the Properties Window which is at the bottom left side of the UserForm, change the Name to “Month_Box”.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |