VBA Combobox Date Format

nadzri

New Member
Joined
Oct 4, 2005
Messages
38
Hi all,

I tried to do this in a userform:
-Display a date value of cell "a1" of "try" sheet in combobox1
-when arrow is press down, combobox display date list from c1:c10
-when new date selected, date cell in "a1" value is changed accordingly

I got all solved by changing the combobox properties:
controlsource: =a1
rowsource: =c1:c10

But i cannot get the date format correctly. When I search the forum i got this:

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

But when new date is selected, it display an error message:
"Run-time error '380': Could not set the Value property. Invalid property value."

What should I do?

Thanks,
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Hi,

You're trying to set the combobox's value to itself. I think your code should read:

Code:
Private Sub ComboBox1_Change() 
Worksheets("Try").Cells(1, 1).Value = Format(ComboBox1.Value, "dd/mm/yyyy") 
End Sub
 
Upvote 0
Hi Rob,

Thanks for your reply, but it still not workin as expected.

I'll try and browse around some more. Will let you know if I found the solution.

Thanks again & have a nice day!
 
Upvote 0

Forum statistics

Threads
1,221,499
Messages
6,160,163
Members
451,628
Latest member
Bale626

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