VBA form Date format

MarkA99

New Member
Joined
Apr 7, 2011
Messages
9
Does anyone know how to the change the date format in a ComboBox on a form when the dates are entered from a worksheets range into an array.
I've tried the format command but it doesn't work in my syntax.

The code which enters the dates is as follows:

Public Sub cboCDate_Enter()
' Routine to populate Course Dates
Sheets("Course_DB").Activate
Dim x&
With Sheets("Course_DB")
For x = 2 To .Cells(Rows.Count, "V").End(xlUp).Row
cboCDate.AddItem (.Range("V" & x).Value)
Next x
End With

cboCDate.Value = Format(cboCDate, "dd/mm/yyyy")
End Sub
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Hi Mark

Just change the Additem line to format it as you eneter it:

cboCDate.AddItem (Format(.Range("V" & x).Value,"dd/mm/yyyy")
 
Upvote 0
Maybe like this

Code:
Public Sub cboCDate_Enter()
' Routine to populate Course Dates
Dim x As Long
With Sheets("Course_DB")
    For x = 2 To .Cells(Rows.Count, "V").End(xlUp).Row
        cboCDate.AddItem Format(.Range("V" & x).Value, "dd/mm/yyyy")
    Next x
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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
Back
Top