TropicalMagic
New Member
- Joined
- Jun 19, 2021
- Messages
- 47
- Office Version
- 365
- Platform
- Windows
I would like to display concatenated dates in the format of DD MMM YYYY.
I have obtained 3 dates, last day 1 month ago, first day 6 months ago and first day 12 months ago, all from today's date.
Here is the code generating my first screenshot:
```
Dim myDate As Date
myDate = Date 'Returns today's date
MyWorkSheetName.Range("A1") = DateSerial(Year(myDate), Month(myDate), 0) 'Returns last day 1 month ago
MyWorkSheetName.Range("B1") = DateSerial(Year(myDate), Month(myDate) - 6, 1) 'Returns first day 6 months ago
MyWorkSheetName.Range("C1") = DateSerial(Year(myDate), Month(myDate) - 12, 1) 'Returns first day 12 months ago
MyWorkSheetName.Range("A3").NumberFormat = "DD MMM YYYY"
MyWorkSheetName.Range("B3").NumberFormat = "DD MMM YYYY"
MyWorkSheetName.Range("C3").NumberFormat = "DD MMM YYYY"
```
Here is my first screenshot:
Here is the result I would like to obtain:
I would like to display them as "01 Feb 2020 - 31 Jul 2021" in a single cell, but concatenating MyWorksheetName.Range("A1").NumberFormat = "DD MMM YYYY" with MyWorksheetName.Range("B1").NumberFormat = "DD MMM YYYY" did not generate the result.
Many thanks!
I have obtained 3 dates, last day 1 month ago, first day 6 months ago and first day 12 months ago, all from today's date.
Here is the code generating my first screenshot:
```
Dim myDate As Date
myDate = Date 'Returns today's date
MyWorkSheetName.Range("A1") = DateSerial(Year(myDate), Month(myDate), 0) 'Returns last day 1 month ago
MyWorkSheetName.Range("B1") = DateSerial(Year(myDate), Month(myDate) - 6, 1) 'Returns first day 6 months ago
MyWorkSheetName.Range("C1") = DateSerial(Year(myDate), Month(myDate) - 12, 1) 'Returns first day 12 months ago
MyWorkSheetName.Range("A3").NumberFormat = "DD MMM YYYY"
MyWorkSheetName.Range("B3").NumberFormat = "DD MMM YYYY"
MyWorkSheetName.Range("C3").NumberFormat = "DD MMM YYYY"
```
Here is my first screenshot:
Here is the result I would like to obtain:
I would like to display them as "01 Feb 2020 - 31 Jul 2021" in a single cell, but concatenating MyWorksheetName.Range("A1").NumberFormat = "DD MMM YYYY" with MyWorksheetName.Range("B1").NumberFormat = "DD MMM YYYY" did not generate the result.
Many thanks!