Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 219
Default convert text month to numeric month

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 913
Default convert text month to numeric month

On Tue, 24 Mar 2009 15:44:22 -0600, 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.


Try this worksheet formula:

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

Hope this helps / Lars-Åke

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 219
Default convert text month to numeric month

On Tue, 24 Mar 2009 22:03:30 GMT, Lars-Åke Aspelin wrote:

On Tue, 24 Mar 2009 15:44:22 -0600, 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.


Try this worksheet formula:

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

Hope this helps / Lars-Åke


Sorry, should have been clear I want to do this in VBA, not in the
spreadsheet.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 245
Default convert text month to numeric month

Debug.Print Month(CVDate(tMth & "-1-2000"))

--
Steve

"salgud" wrote in message
...
On Tue, 24 Mar 2009 22:03:30 GMT, Lars-Åke Aspelin wrote:

On Tue, 24 Mar 2009 15:44:22 -0600, 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.


Try this worksheet formula:

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

Hope this helps / Lars-Åke


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


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 245
Default convert text month to numeric month

Forgot to add tMth is your text month.

--
Steve

"AltaEgo" <Somewhere@NotHere wrote in message
...
Debug.Print Month(CVDate(tMth & "-1-2000"))

--
Steve

"salgud" wrote in message
...
On Tue, 24 Mar 2009 22:03:30 GMT, Lars-Åke Aspelin wrote:

On Tue, 24 Mar 2009 15:44:22 -0600, 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.

Try this worksheet formula:

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

Hope this helps / Lars-Åke


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




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 219
Default convert text month to numeric month

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?
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default convert text month to numeric month

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.

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default convert text month to numeric month

One way
mymonthnum = Month(DateValue(Range("i2") & " 1,2009"))



--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"salgud" wrote in message
.. .
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.


  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default convert text month to numeric month

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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
convert date to text month april Excel Discussion (Misc queries) 2 March 3rd 10 06:18 PM
Function or formula to convert "text" month to number of month? Steve Vincent Excel Discussion (Misc queries) 5 May 15th 07 01:11 AM
Converting Month Number to Month Text Abbreviation Bob Excel Worksheet Functions 10 May 12th 07 04:11 AM
Function or formula to convert "text" month to number of month? Kevin Vaughn Excel Discussion (Misc queries) 0 February 4th 06 04:45 PM
Function or formula to convert "text" month to number of month Steve Vincent Excel Discussion (Misc queries) 1 February 4th 06 04:19 PM


All times are GMT +1. The time now is 04:43 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"