Calculating numerical month (1 to 12) from text date

C

Claire_S

I have extracted the month from the worksheet name using the CELL function to
give me the month name as text. Is there a way I can convert this to a
numerical month?
 
P

Pete_UK

If you list those months in order in a block of cells somewhere, eg
starting in X1:

January
February
March

etc., then you can use this:

=MATCH(TRIM(D2),X$1:X$12,0)

assuming your months are in column D. Copy down as required.

Hope this helps.

Pete
 
G

Gary''s Student

Say the file name is something like 18 January 1863.xls

In B1 thru B3 enter:

=CELL("filename",A1)
=MID(B1,47,15)
=MONTH(DATEVALUE(B2))

to display:

C:\Documents and Settings\Owner\My Documents\[18 January 1963.xls]Sheet1
18 January 1963
1

This gets you the "1" for January.
 
B

barry houdini

But wouldn't that get screwed up if the next filename was 8 May 2007.xls?
--
David Biddulph



Gary''s Student said:
Say the file name is something like 18 January 1863.xls
In B1 thru B3 enter:

to display:
C:\Documents and Settings\Owner\My Documents\[18 January
1963.xls]Sheet1 18 January 1963
1
This gets you the "1" for January.

- Show quoted text -

With text month in A1

=MONTH(A1&1)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top