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,156
  • 6
  • 41
  • 73
Niko.K
  • 277
  • 3
  • 17

2 Answers2

2

Do it like this:

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

Here it is -

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

Range("F3").NumberFormat = "yyyy-mm-dd"
Jean-François Corbett
  • 36,032
  • 27
  • 135
  • 183
Praveen Behera
  • 416
  • 2
  • 5
  • 13