ComboBox Dates

deepheat101

Board Regular
Joined
Jul 26, 2006
Messages
138
Hi All...

I need all the drop down items (dates) within a ComboBox on a form to appear in the format dd-Mmm-yyyy. The source range is in the required format. I would have thought that the ComboBox would be populated using the following...

Code:
    ComboBox1.List = Format(Range("F18:F" & LastRow).Value, "dd-Mmm-yyyy")

...but, obviously, this does not work. Anyone care to offer a suggestion?

Many Thanks

Dave
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
Try:

ComboBox1.RowSource = Range("F18:F" & LastRow).Address(0,0)

Make sure the right sheet is the ActiveSheet though.
 

tmcfadden

Board Regular
Joined
Aug 17, 2005
Messages
151
I'm not sure how to get Format() to accept and return a range.

You can always throw it into a loop:
<hr>
Code:
For Each cell In Range("F18:F" & LastRow)
    ComboBox1.AddItem Format(cell, "dd-Mmm-yyyy")
Next cell

-Tim
 

deepheat101

Board Regular
Joined
Jul 26, 2006
Messages
138
Peeps - many thanks - both suggestions do the job! However, (for those that stumble across this solution later), tmcfadden's returns the selected date in the date format - rather than a number.

Many Thanks again.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,168,028
Messages
5,856,932
Members
431,839
Latest member
Guest user

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