ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Format Date ComboBox (https://www.excelbanter.com/excel-discussion-misc-queries/172419-format-date-combobox.html)

Blobbies

Format Date ComboBox
 
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

TWR

Format Date ComboBox
 
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" wrote:

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


[email protected]

Format Date ComboBox
 
On Jan 9, 8:49*pm, Blobbies
wrote:
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

Blobbies

Format Date ComboBox
 
Hi TWR

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

Many thanks



Edi


"TWR" wrote:

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" wrote:

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


Blobbies

Format Date ComboBox
 
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

" wrote:

On Jan 9, 8:49 pm, Blobbies
wrote:
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



All times are GMT +1. The time now is 12:05 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com