Format Date ComboBox

B

Blobbies

I have a userform that has two date comboboxes.

The second combobox dates (days of the applicable working week) are reliant
on the whatever date (paydate) is selected.

The listed dates within each combo box are in the format [dd-mm-yy], but
once they are selected on the userform, they revert to a serial number date.

Is the anyway of retaining the [dd-mm-yy] format when the date is selected
on the userform?

Many thanks in advance for your help!!!



Edi, NZ
 
T

TWR

You may want to ask this question in the Excel Programming section, rather
than the General Questions section.

Do the second combo's values change based on the selection in the first combo?
 
A

adam_kroger

I have a userform that has two date comboboxes.

The second combobox dates (days of the applicable working week) are reliant
on the whatever date (paydate) is selected.

The listed dates within each combo box are in the format [dd-mm-yy], but
once they are selected on the userform, they revert to a serial number date.

Is the anyway of retaining the [dd-mm-yy] format when the date is selected
on the userform?

Many thanks in advance for your help!!!

Edi, NZ

I had the same issue. You have to format the combo box using VBA.
There is probably a better way, but this one works.

Private Sub ComboBox1_Change()
MyDate = Format(ComboBox1.Value, "mm/d/yyyy")
ComboBox1.Value = Format(MyDate, "mm/d/yyyy")
End Sub
 
B

Blobbies

Hi TWR

Thanks for the time you took to consider my problem!! Adam has helped me
out below !!

Many thanks



Edi


TWR said:
You may want to ask this question in the Excel Programming section, rather
than the General Questions section.

Do the second combo's values change based on the selection in the first combo?

Blobbies said:
I have a userform that has two date comboboxes.

The second combobox dates (days of the applicable working week) are reliant
on the whatever date (paydate) is selected.

The listed dates within each combo box are in the format [dd-mm-yy], but
once they are selected on the userform, they revert to a serial number date.

Is the anyway of retaining the [dd-mm-yy] format when the date is selected
on the userform?

Many thanks in advance for your help!!!



Edi, NZ
 
B

Blobbies

Thanks Adam - That seems to work a treat, although upsets things further on
in the code when it's simply searching for the date in General format, and
it's been converted to dd/mm/yy!! Nevermind .... I'll work my way around
that!!


Cheers!!



Edi

I have a userform that has two date comboboxes.

The second combobox dates (days of the applicable working week) are reliant
on the whatever date (paydate) is selected.

The listed dates within each combo box are in the format [dd-mm-yy], but
once they are selected on the userform, they revert to a serial number date.

Is the anyway of retaining the [dd-mm-yy] format when the date is selected
on the userform?

Many thanks in advance for your help!!!

Edi, NZ

I had the same issue. You have to format the combo box using VBA.
There is probably a better way, but this one works.

Private Sub ComboBox1_Change()
MyDate = Format(ComboBox1.Value, "mm/d/yyyy")
ComboBox1.Value = Format(MyDate, "mm/d/yyyy")
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top