Red over White
Board Regular
- Joined
- Jul 16, 2011
- Messages
- 127
- Office Version
- 365
- Platform
- MacOS
The solution is probably very simple, but is beyond me. I have been trying to resolve the above problem, which is part of a much bigger macro in which I have been able to put various strings and numbers in successfully by using input boxes. The specific code I am struggling with:
Sub InputDate()
Dim Caption2G As String
Dim Prompt2G As String
Dim EDate As Date
Caption2G = "Maturity Date"
Prompt2G = "Enter Date"
EDate = Val(InputBox(Prompt2G, Caption2G, Format(EDate, "dd/mm/yyyy")))
ActiveSheet.Cells(1, 1) = EDate
End Sub
When the Input Box the date "31/12/1899" appears which I'm not too bothered about (unless I am missing something fundamental). It will accept a new date but when it is transferred to cell A1 only the "dd" element of the date appears correctly, the rest of the date appears as "/01/00". A1 is formatted "dd/mm/yy".
How do I get the whole of the date, for example "02/08/2023" (the date will always be later than today), transferred to A1 so that it shows in the correct "dd/mm/yy" format?
Thanks
Sub InputDate()
Dim Caption2G As String
Dim Prompt2G As String
Dim EDate As Date
Caption2G = "Maturity Date"
Prompt2G = "Enter Date"
EDate = Val(InputBox(Prompt2G, Caption2G, Format(EDate, "dd/mm/yyyy")))
ActiveSheet.Cells(1, 1) = EDate
End Sub
When the Input Box the date "31/12/1899" appears which I'm not too bothered about (unless I am missing something fundamental). It will accept a new date but when it is transferred to cell A1 only the "dd" element of the date appears correctly, the rest of the date appears as "/01/00". A1 is formatted "dd/mm/yy".
How do I get the whole of the date, for example "02/08/2023" (the date will always be later than today), transferred to A1 so that it shows in the correct "dd/mm/yy" format?
Thanks