How to Use Calendar Control in VBA Excel

Written by jaime avelar
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Use Calendar Control in VBA Excel
A calendar control is used to choose a date that you can then apply in your application. (calendar 2007 image by Franc Podgor...¡ek from Fotolia.com)

Knowing how to use a calendar control in Microsoft Office Excel can make your application more dynamic. Excel is a spreadsheet application commonly used to analyse large amounts of data. Visual Basic for Applications (VBA) is a computer programming language developed by Microsoft to automate routine tasks in Microsoft Office applications. A calendar control is used to choose a date that you can then apply in your application.

Skill level:
Easy

Other People Are Reading

Instructions

  1. 1

    Start Microsoft Office Excel, select the "Developer" tab then click "Visual Basic." Click the "Insert" menu and select "UserForm."

  2. 2

    Right-click the "Toolbox" menu and select "Additional Controls...". Check the box next to "Calendar Control 12.0" then click "OK."

  3. 3

    Click the calendar control and add it to "UserForm1." Click the "CommandButton" control and add one to your "UserForm1." Double-click the "CommandButton1" to open Microsoft Visual Basic.

  4. 4

    Copy and paste the code below inside the "CommandButton1_Click()" subroutine.

    Dim data String As String

    data String = Calendar1.Value

    ActiveCell = data String

    ActiveCell.NumberFormat = "mm/dd/yy"

  5. 5

    Press "F5" to run the program then click "CommandButton1." The program will get the calendar date chosen by user and will add it to the active cell in the Excel spreadsheet.

Don't Miss

Filter:
  • All types
  • Articles
  • Slideshows
  • Videos
Sort:
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the eHow.co.uk site, you consent to the use of cookies. For more information, please see our Cookie policy.