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
 

Some videos you may like

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

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.
 

Watch MrExcel Video

Forum statistics

Threads
1,114,401
Messages
5,547,740
Members
410,810
Latest member
thepinkbird
Top