OilEconomist
Active Member
- Joined
- Dec 26, 2016
- Messages
- 439
- Office Version
- 2019
- Platform
- Windows
Thanks in advance for your assistance. How can I take the MS Excel formula:
and transform it into a VBA Code
Basically I want to take a column C which has date values in a text format such as “2019-11-04 @ 15:03” and in a column F, transform it into the format of month number and month name. Here is how it would look for the various months, but the issue is it gives me the date. It will show: "11 November" but it the cell it has it as the date 11/4/2019.
01 January
02 February
03 March
04 April
05 May
06 June
07 July
08 August
09 September
10 October
11 November
12 December
The code I have written is as follows, but there is in issue with this line:
as it's returning a full date.
Excel Formula:
= CONCATENATE( TEXT(RIGHT(LEFT($C9,7), 2), "00"), " ", TEXT( (RIGHT(LEFT($C9, 7), 2) ) * 29, "MMMM") )
Basically I want to take a column C which has date values in a text format such as “2019-11-04 @ 15:03” and in a column F, transform it into the format of month number and month name. Here is how it would look for the various months, but the issue is it gives me the date. It will show: "11 November" but it the cell it has it as the date 11/4/2019.
01 January
02 February
03 March
04 April
05 May
06 June
07 July
08 August
09 September
10 October
11 November
12 December
The code I have written is as follows, but there is in issue with this line:
VBA Code:
"= CONCATENATE( TEXT( RIGHT(LEFT($C9, 7), 2), ""00""), "" "", TEXT(( RIGHT( LEFT($C9, 7), 2))*29, ""MMMM"" ) )"
VBA Code:
Sub DtFrmt()
Dim LastRow As Long
Sheets("Sheet1").Activate
With Sheets("Sheet1")
LastRow = .Cells.Find(What:="*", after:=.Cells(1), SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
End With
Range("F9:F" & LastRow).Formula = _
"= CONCATENATE( TEXT( RIGHT(LEFT($C9, 7), 2), ""00""), "" "", TEXT(( RIGHT(LEFT($C9, 7), 2))*29, ""MMMM"") )"
Range("F9:F" & LastRow).Value = Range("F9:F" & LastRow).Value
End Sub