0

I have an Userform where you get the dates from a Table. The Dates in this Table are in "dd/mm/yy" format. When you get the Dates it appears like this:

enter image description here

I can write a new date on either of the textboxes and with the Modify Button I can modify the dates in my Table.

The problem is that when the new dates appear in the Table, they change format and turn into mm/dd/yy.

I'm already using format when putting the date in the text box and when puting it in the Table:

'putting date in Text Box:
FMDateEditor.tbFechaRecibida.Text = Format(MainCode.myRange.Cells(MainCode.EditIndexFechas, shMaster.ListObjects("MasterTable").ListColumns("Fecha recibida").index).Value, "dd/mm/yy")
'
'Puttting date in Table:
MainCode.myRange.Cells(MainCode.EditIndexFechas, shMaster.ListObjects("MasterTable").ListColumns("Fecha recibida").index).Value = Format(FMDateEditor.tbFechaRecibida.Text, "dd/mm/yy")

But the problem Persists

The cells in the Table have "dd/mm/yy" format.

Thanks for the help

David YL
  • 13
  • 5
  • You may want to see these? [Formatting MM/DD/YYYY dates in textbox in VBA](https://stackoverflow.com/questions/12012206/formatting-mm-dd-yyyy-dates-in-textbox-in-vba) and [Taking Calendar to new level](https://stackoverflow.com/questions/54650417/how-can-i-create-a-calendar-input-in-vba-excel) – Siddharth Rout Jan 06 '21 at 05:53

1 Answers1

0

Excel stores dates as a number representing the mm/dd/yyyy format and performs all its calculations in this format. So avoid applying date formats when assigning from a variable to a variable (or using in calculations)

Try:

FMDateEditor.tbFechaRecibida.Text = _
Format(MainCode.myRange.Cells(MainCode.EditIndexFechas, _
shMaster.ListObjects("MasterTable"). _
ListColumns("Fecha recibida").Index).Value, "dd/mm/yy") & ""
Siddharth Rout
  • 147,039
  • 17
  • 206
  • 250
  • _Excel stores dates as a number representing the mm/dd/yyyy format_ ... No. Excel stores dates as numbers having no format. – Gustav Jan 06 '21 at 08:40