Category: [Excel] Demo Available
Excel Calendar Control-Create an Excel Calendar
Got any Excel/VBA Questions? Free Excel Help
Excel Calendar. One very common problem encountered by most Excel users is the correct entering of excel dates. When a date is not entered in the correct format Excel will not recognize it as a valid date. This often means you can not perform calculations with the 'so-called' dates. It also means any charts, Pivot tables etc based off the dates will not be valid. While the use of Excels Validation can help with this it is far from bullet proof. Below is a quite simple way we can have all our dates entered in Excel correctly. Just follow the steps and you will be up and running in 10 minutes.
- Open The Workbook For The Calendar. It Is A Good Idea To Use Your Personal.Xls For This, In Which Case You Should First Go To Window>Unhide
- Go To Tools>Macro>Visual Basic Editor (Alt+F11).
- Go To Insert>UserForm From Within The VBE. This Should Automatically Display The Control Toolbox, If Not Go To View>Toolbox
- Right Click On The Toolbox And Select Additional Controls
- Scroll Through The List Until You See: Calendar Control 10.0 (Number Will Differ Depending On Excel Version) And Check The Checkbox And Click OK
- Now Click The Calendar That Is Now Part Of The Toolbox And Then Click On The UserForm We Inserted In Step 3.
- Use The Size Handles On Both The UserForm And The Calendar Control To Make Them Both A Reasonable Size. See Example Below.
- Now Ensure The UserForm Is Selected (As Shown Above) Then Go To View>Properties Window (F4)
- Select Caption From The Properties Window And Replace: UserForm1 With The Word Calendar.
- Now Go To View>Code (F7) And In The White Private Module In Front Of You, Add The Code Exactly As Show Below:
Private Sub Calendar1_Click()
ActiveCell = Calendar1.Value
Private Sub UserForm_Activate()
Me.Calendar1.Value = Date
- Now Go To Insert>Module And In This Public Module Place This Code
- Ok, Nearly Done. Click The Top Right X (Or Push Alt+F11) To Return Back To Excel.
- Go To Tools>Macro>Macros (Alt+F8) And Then Select ShowIt Click Options And Assign A Shortcut Key And You're Done.
All you need to do now is push your shortcut key and the Calendar will show with today's date as the default. Click any date and it will be inserted into the active cell. This ensures that any date entered is valid and it is a lot easier for the user.
If you do not have this Control, go here and scroll down to "Office Calendar Control Not Working"
Free Training Course: Lesson 1 - Excel Fundamentals
See also: Index to Excel VBA Code; Index to Excel Freebies; Lesson 1 - Excel Fundamentals; Index to how to… providing a range of solutions
Click here to visit our Free 24/7 Excel/VBA Help Forum where there are thousands of posts you can get information from, or you can join the Forum and post your own questions.