3

I am typing in my textbox in excel following: 2017-01-09 the result posted in the cell is 42744

What am I doing wrong here even do I am specifically saying that my cell should be formatted as a 'general' type

Private Sub TextBox2_LostFocus()
        Range("F3").Value = TextBox2.Value
        Range("F3").NumberFormat = "General"
        Range("F3").Select
        Application.SendKeys ("~")
        Range("F3").NumberFormat = "General"
End Sub
R3uK
  • 14,417
  • 7
  • 43
  • 77
Niko.K
  • 297
  • 4
  • 17

2 Answers2

2

Do it like this:

With Range("F3") 
 .NumberFormat = "yyyy-mm-dd"
 .FormulaR1C1 = "2017-01-09"
End With
AnalystCave.com
  • 4,884
  • 2
  • 22
  • 30
2

Here it is -

Range("F3").Value = TextBox2.Text

Range("F3").NumberFormat = "yyyy-mm-dd"
Jean-François Corbett
  • 37,420
  • 30
  • 139
  • 188
Praveen Behera
  • 444
  • 2
  • 8
  • 17