Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Add Date Picker To VBA UserForm

Tags:

excel

vba

I am looking for a control to add to userForm to enable a user to pick the date. I found a good one at this address

Formatting MM/DD/YYYY dates in textbox in VBA

from Siddharth Rout which is perfect but it generates invisible sheets which is not necessary for my application. I tried to stop creating sheets but I couldn't figure it out.

Can you please let me know how I can properly modify the Siddharth Rout code or point me to another application like that?

Thanks for your time

like image 249
user1760110 Avatar asked Nov 16 '12 02:11

user1760110


People also ask

How do I insert a calendar into Excel VBA?

On the File menu, select Close and Return to Microsoft Excel. Select the Sheet1 tab. On the Tools menu, point to Macro, and then select Macros. Select CalendarMaker, and then select Run to create the calendar.


1 Answers

OFFICE 2013 INSTRUCTIONS:

(For Windows 7 (x64) | MS Office 32-Bit)

Option 1 | Check if ability already exists | 2 minutes

  1. Open VB Editor
  2. Tools -> Additional Controls
  3. Select "Microsoft Monthview Control 6.0 (SP6)" (if applicable)
  4. Use 'DatePicker' control for VBA Userform

Option 2 | The "Monthview" Control doesn't currently exist | 5 minutes

  1. Close Excel
  2. Download MSCOMCT2.cab (it's a cabinet file which extracts into two useful files)
  3. Extract Both Files | the .inf file and the .ocx file
  4. Install | right-click the .inf file | hit "Install"
  5. Move .ocx file | Move from "C:\Windows\system32" to "C:\Windows\sysWOW64"
  6. Run CMD | Start Menu -> Search -> "CMD.exe" | right-click the icon | Select "Run as administrator"
  7. Register Active-X File | Type "regsvr32 c:\windows\sysWOW64\MSCOMCT2.ocx"
  8. Open Excel | Open VB Editor
  9. Activate Control | Tools->References | Select "Microsoft Windows Common Controls 2-6.0 (SP6)"
  10. Userform Controls | Select any userform in VB project | Tools->Additional Controls
  11. Select "Microsoft Monthview Control 6.0 (SP6)"
  12. Use 'DatePicker' control for VBA UserForm

Okay, either of these two steps should work for you if you have Office 2013 (32-Bit) on Windows 7 (x64). Some of the steps may be different if you have a different combo of Windows 7 & Office 2013.

The "Monthview" control will be your fully fleshed out 'DatePicker'. It comes equipped with its own properties and image. It works very well. Good luck.

Site: "bonCodigo" from above (this is an updated extension of his work)
Site: "AMM" from above (this is just an exension of his addition)
Site: Various Microsoft Support webpages

like image 142
Elias Avatar answered Sep 21 '22 14:09

Elias