Displaying date formats on Combo Box (ActiveX Control)

willow1985

Well-known Member
Joined
Jul 24, 2019
Messages
888
Office Version
  1. 365
Platform
  1. Windows
I read an article on how to format a date in a combo box using VBA: How to display date format in combo box output in Excel?

the code for the combo box is:

VBA Code:
Private Sub ComboBox_Date()
ActiveSheet.Date_Start.Value = Format(ActiveSheet.Date_Start.Value, "mmmm d,yyyy")
ActiveSheet.Date_End.Value = Format(ActiveSheet.Date_End.Value, "mmmm d,yyyy")
End Sub

Now this works when I manually run the code in VBA however every time I change my selection in the combo box it does not reformat it and the selection goes back to numbers (see below)
Any idea's on how to get the code to run when I make a different selection?

Also, how can I also convert the Linked Cell to a number/date a formula will recognize?
 

Attachments

  • BeforeAfter.jpg
    BeforeAfter.jpg
    30.5 KB · Views: 37
Last edited by a moderator:

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
The link you posted answers your first question. Use the Click event to run the macro instead of running it manually. BTW how are you populating the combo box to start with?

VBA Code:
Private Sub Date_Start_Click()
    ActiveSheet.Date_Start.Value = Format(ActiveSheet.Date_Start.Value, "mmmm d,yyyy")
End Sub

For the second question, how are you using the linked cell?
 
Upvote 0
Solution
I had the click event wrong. Also, not sure what happened but the result on the linked cells will work as long as my formula that is referencing those linked cells/dates compensate for the fact they are a value.

Everything seems to be working.

Thank you very much!
 
Upvote 0

Forum statistics

Threads
1,214,835
Messages
6,121,880
Members
449,057
Latest member
Moo4247

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