How to Use Calendar Control in VBA Excel

How to Use Calendar Control in VBA Excel thumbnail
A calendar control is used to choose a date that you can then apply in your application.

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 analyze 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.

Instructions

    • 1

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

    • 2

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

    • 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

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

      Dim dataString As String

      dataString = Calendar1.Value

      ActiveCell = dataString

      ActiveCell.NumberFormat = "mm/dd/yy"

    • 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.

Related Searches:

References

  • Photo Credit calendar 2007 image by Franc Podgor...¡ek from Fotolia.com

Comments

You May Also Like

Related Ads

Featured