Displaying date formats on Combo Box (ActiveX Control)

willow1985

Well-known Member
Joined
Jul 24, 2019
Messages
725
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: 11
Last edited by a moderator:

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

6StringJazzer

Well-known Member
Joined
Jan 27, 2010
Messages
857
Office Version
  1. 365
Platform
  1. Windows
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?
 
Solution

willow1985

Well-known Member
Joined
Jul 24, 2019
Messages
725
Office Version
  1. 365
Platform
  1. Windows
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!
 

Watch MrExcel Video

Forum statistics

Threads
1,132,914
Messages
5,655,930
Members
418,253
Latest member
TheJackal26

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
Top