Format ActiveX Dropdown Display

Mayanwolfe

New Member
Joined
Jun 5, 2013
Messages
27
Hello you helpful folks,

I have an ActiveX dropdown box from which the user may select a date formatted thusly: MM/DD/YYYY. The dates display perfectly in the dropdown list, but once one is selected, it shows up as the Excel numeral code in the box (such as 41548). How do I change this so that the selected date shows up in the form MM/DD/YYYY?

Thanks!
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
[SOLVED] This seems to be a fairly common problem, so in case anyone else is wondering, I have found the solution:

1. In the Developer tab, put the sheet into Design Mode.
2. Right-click on your ComboBox and select View Code
3. In the VBA window, enter the following code (replace the name DateBox with whatever you have named your ComboBox):

Private Sub DateBox_Change()
DateBox.Value = Format(DateBox.Value, "mm/dd/yyyy")
End Sub

4. Close the VBA window, take the sheet out of Design Mode, and select dates at your leisure!

You can modify the "mm/dd/yyyy" format in the code to whatever your display needs may be, and output the result to a linked cell for use in subsequent formulas. However, be advised that the output will be read as text and not as a date and therefore could cause problems if you try to read it directly into a formula. To fix this issue, in an adjacent cell, enter this formula (let's say the ComboBox is linked to A1): =--A1. The result will be a date that you may format and use in formulas.

Hope that may help someone!
Mayanwolfe
 
Upvote 0

Forum statistics

Threads
1,222,830
Messages
6,168,509
Members
452,194
Latest member
Lowie27

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top