0

I have this strange problem. When I use this function

Worksheets("Worksheet").Cells(2, 8).Value = ComboBox2.Value

Where my ComboBox2.Value = 02/01/2019 I got the following output in Cells(2,8) --> 01/02/2019

But in my cell properties I have already set that I want "dd/mm/yyyy"

Where is the problem?

9
  • 1
    Probably in your Regional settings in your computer system, got some issues with that.
    – Teamothy
    Commented Oct 2, 2019 at 12:25
  • Does using .Value2 change anything? Commented Oct 2, 2019 at 12:25
  • @M.Schalk No it doesn't change anything Commented Oct 2, 2019 at 12:27
  • @SometingNew Keep ComboBox2.Value as it is, use .Value2 for the cell Commented Oct 2, 2019 at 12:28
  • how do you set the combobox values?
    – SNicolaou
    Commented Oct 2, 2019 at 12:29

1 Answer 1

3

i would convert to a date the combobox value. tried (replicated) your issue and this fix worked for me. basically, use CDate to set the cell value.

Private Sub ComboBox1_Change()

  Dim v As Variant
  Dim d As Date

  v = Me.ComboBox1.Value
  d = CDate(v)

  Sheet3.Range("A1").Value = d

End Sub
1
  • obviously, change/rename accordingly :-)
    – SNicolaou
    Commented Oct 2, 2019 at 12:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.