Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try the following code:
Sub alpha() ' Declare the variables Dim rngCell As Range Dim strMonthName As String Dim intMonthNumber As Integer ' Investigate the worksheet entries For Each rngCell In ActiveSheet.UsedRange ' Initalize the variables strMonthName = rngCell.Value intMonthNumber = Month(DateValue(strMonthName & " 1, 1969")) ' Rewrite cell value if a month If intMonthNumber = 1 And intMonthNumber <= 12 Then _ rngCell.Value = intMonthNumber Next rngCell End Sub Regards, Alasdair Stirling "quartz" wrote: On a sheet there are numerous cells containing month names written out (e.g. June, December, etc.). I need to convert these to their ordinal values (e.g. January = 1; June = 6, etc.). Can anyone post some example code that easily converts these short of having to do a case select with 12 cases? Thanks much in advance. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Functions for "current" & "previous" month to calculate data | Excel Worksheet Functions | |||
Function or formula to convert "text" month to number of month? | Excel Discussion (Misc queries) | |||
Function or formula to convert "text" month to number of month? | Excel Discussion (Misc queries) | |||
Function or formula to convert "text" month to number of month | Excel Discussion (Misc queries) | |||
Convert "Month" to "MonthName" format from db to PivotTable | Excel Programming |