-1
Context: I have the following code that receives from the user a date:
dataAtualDefault = Day(Date) & "/" & Month(Date) & "/" & Year(Date)
dataInsercao = Application.InputBox("Data da entrada", "Entrada", dataAtualDefault)
Problem: if the user commits a typo and enters a date when the month is greater than 12, such as 09/15/2020, the value of the month is reversed with that of the day, and the variable becomes the following value: 15/09/2020
Solutions I have tried but failed:
- This did not work because the month and day are reversed before the
If
If(Month(dataInsercao ) > 12) Then
MsgBox("Erro!")
End If
Format
doesn’t help because it converts to a String, but I really need the variable to be of the Date type
Format(dataInsercao , "dd/mm/yyyy")
It is not that, it is that the date is in the American that is
mês/dia/ano
, what you will do with the date?– novic
Yes, it is in US format. But how to remove it? The date provided by the user will be inserted in a column with several other dates. Then, the date entered by the user is compared with the others to know if the organization of all dates should be made
– Guilherme Umemura
if you are entering where? ta confused your question
– novic
The date is inserted in an excel column
– Guilherme Umemura