PC Review


Reply
Thread Tools Rate Thread

convert text month to numeric month

 
 
salgud
Guest
Posts: n/a
 
      24th Mar 2009
I just asked here how to do the opposite. How do I convert "May" to 5
without using a case statement? I've looked all over on the net, but can't
find this specific thing.

Thanks in advance.
 
Reply With Quote
 
 
 
 
Lars-Åke Aspelin
Guest
Posts: n/a
 
      24th Mar 2009
On Tue, 24 Mar 2009 15:44:22 -0600, salgud <(E-Mail Removed)>
wrote:

>I just asked here how to do the opposite. How do I convert "May" to 5
>without using a case statement? I've looked all over on the net, but can't
>find this specific thing.
>
>Thanks in advance.


Try this worksheet formula:

=SUMPRODUCT(ROW(1:12)*(TEXT(DATE(,ROW(1:12),1),"MMM")="May"))

Hope this helps / Lars-Åke

 
Reply With Quote
 
salgud
Guest
Posts: n/a
 
      24th Mar 2009
On Tue, 24 Mar 2009 22:03:30 GMT, Lars-Åke Aspelin wrote:

> On Tue, 24 Mar 2009 15:44:22 -0600, salgud <(E-Mail Removed)>
> wrote:
>
>>I just asked here how to do the opposite. How do I convert "May" to 5
>>without using a case statement? I've looked all over on the net, but can't
>>find this specific thing.
>>
>>Thanks in advance.

>
> Try this worksheet formula:
>
> =SUMPRODUCT(ROW(1:12)*(TEXT(DATE(,ROW(1:12),1),"MMM")="May"))
>
> Hope this helps / Lars-Åke


Sorry, should have been clear I want to do this in VBA, not in the
spreadsheet.
 
Reply With Quote
 
ryguy7272
Guest
Posts: n/a
 
      24th Mar 2009
Here is one way:
=CHOOSE(MATCH(A1,{"Jan";"Feb";"Mar";"Apr";"May"},1),"1","2","3","4","5")

Another way:
=LOOKUP(A17,{"Jan","Feb","Mar","Apr","May"},{"1","2","3","4","5"})


HTH,
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"salgud" wrote:

> I just asked here how to do the opposite. How do I convert "May" to 5
> without using a case statement? I've looked all over on the net, but can't
> find this specific thing.
>
> Thanks in advance.
>

 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      24th Mar 2009
One way
mymonthnum = Month(DateValue(Range("i2") & " 1,2009"))



--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"salgud" <(E-Mail Removed)> wrote in message
news:zsffhhqi5yyd$.1f36a33efjg2i$.(E-Mail Removed)...
>I just asked here how to do the opposite. How do I convert "May" to 5
> without using a case statement? I've looked all over on the net, but can't
> find this specific thing.
>
> Thanks in advance.


 
Reply With Quote
 
Jacob Skaria
Guest
Posts: n/a
 
      25th Mar 2009
strMonth = "May"
intMonth = Month("01-" & strMonth & "-" & Year(Date))

If this post helps click Yes
---------------
Jacob Skaria

"salgud" wrote:

> I just asked here how to do the opposite. How do I convert "May" to 5
> without using a case statement? I've looked all over on the net, but can't
> find this specific thing.
>
> Thanks in advance.
>

 
Reply With Quote
 
AltaEgo
Guest
Posts: n/a
 
      26th Mar 2009
Debug.Print Month(CVDate(tMth & "-1-2000"))

--
Steve

"salgud" <(E-Mail Removed)> wrote in message
news:a5yoa2x0z78l$.(E-Mail Removed)...
> On Tue, 24 Mar 2009 22:03:30 GMT, Lars-Åke Aspelin wrote:
>
>> On Tue, 24 Mar 2009 15:44:22 -0600, salgud <(E-Mail Removed)>
>> wrote:
>>
>>>I just asked here how to do the opposite. How do I convert "May" to 5
>>>without using a case statement? I've looked all over on the net, but
>>>can't
>>>find this specific thing.
>>>
>>>Thanks in advance.

>>
>> Try this worksheet formula:
>>
>> =SUMPRODUCT(ROW(1:12)*(TEXT(DATE(,ROW(1:12),1),"MMM")="May"))
>>
>> Hope this helps / Lars-Åke

>
> Sorry, should have been clear I want to do this in VBA, not in the
> spreadsheet.


 
Reply With Quote
 
AltaEgo
Guest
Posts: n/a
 
      26th Mar 2009
Forgot to add tMth is your text month.

--
Steve

"AltaEgo" <Somewhere@NotHere> wrote in message
news:#(E-Mail Removed)...
> Debug.Print Month(CVDate(tMth & "-1-2000"))
>
> --
> Steve
>
> "salgud" <(E-Mail Removed)> wrote in message
> news:a5yoa2x0z78l$.(E-Mail Removed)...
>> On Tue, 24 Mar 2009 22:03:30 GMT, Lars-Åke Aspelin wrote:
>>
>>> On Tue, 24 Mar 2009 15:44:22 -0600, salgud <(E-Mail Removed)>
>>> wrote:
>>>
>>>>I just asked here how to do the opposite. How do I convert "May" to 5
>>>>without using a case statement? I've looked all over on the net, but
>>>>can't
>>>>find this specific thing.
>>>>
>>>>Thanks in advance.
>>>
>>> Try this worksheet formula:
>>>
>>> =SUMPRODUCT(ROW(1:12)*(TEXT(DATE(,ROW(1:12),1),"MMM")="May"))
>>>
>>> Hope this helps / Lars-Åke

>>
>> Sorry, should have been clear I want to do this in VBA, not in the
>> spreadsheet.

>

 
Reply With Quote
 
salgud
Guest
Posts: n/a
 
      31st Mar 2009
On Fri, 27 Mar 2009 09:42:11 +1100, AltaEgo wrote:

> Forgot to add tMth is your text month.


Thanks for trying, but that formula doesn't work, it always returns Jan.
Any other suggestions?
 
Reply With Quote
 
salgud
Guest
Posts: n/a
 
      1st Apr 2009
On Thu, 2 Apr 2009 10:35:43 +1100, AltaEgo wrote:

> Hmmmmm
>
> 1) Enter the values below in A1 to A12
> Jan
> Feb
> Mar
> Apr
> May
> Jun
> Jul
> Aug
> Sep
> Oct
> Nov
> Dec
>
> 2) In a general module, copy the following function:
>
> Function test(tMth As Range)
>
> test = Month(CVDate(tMth.Value & "-1-2000"))
>
> End Function
>
> 3) Enter "=test" (without quotes) in B1.
> 4) copy down to B12
>
> I get the numbers 1 to 12 in XL 2003.


Thanks again. I ended up using Don's method. (see below)
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Access 2003 convert numeric month to text for reports M G Henry Microsoft Access Reports 2 20th Jan 2010 10:52 PM
RE: convert month text (MAR) to month number (3) Jerry Whittle Microsoft Access Queries 0 10th Dec 2009 09:00 PM
Function or formula to convert "text" month to number of month? =?Utf-8?B?U3RldmUgVmluY2VudA==?= Microsoft Excel Misc 5 15th May 2007 01:11 AM
RE: Function or formula to convert "text" month to number of month? =?Utf-8?B?S2V2aW4gVmF1Z2hu?= Microsoft Excel Misc 0 4th Feb 2006 04:45 PM
Convert month number to month text =?Utf-8?B?Q29zbWlj?= Microsoft Access Forms 1 1st Oct 2004 04:08 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:19 AM.