+ Reply to Thread
Results 1 to 7 of 7

Convert two digit month (ex 10) to full Month Name in Variable

  1. #1
    Registered User
    Join Date
    04-11-2013
    Location
    Las Vegas
    MS-Off Ver
    Excel 2007
    Posts
    26

    Lightbulb Convert two digit month (ex 10) to full Month Name in Variable

    Yep.
    I have tried everything and now i put it out to the experts as I just cant get this to work. I thought it would be simple. here is the code

    variables: MO = 10
    YR = 2011

    I am trying to take MO which is represented as a two digit number and turn it into its full month name and store that in a variable called vMonth.

    this just does not work......vMonth = vMonth = Text(DATE(vYear,MO,1),"MMMM")

    It works in a spreadsheet where i enter =Text(DATE(vYear,MO,1),"MMMM")
    where vYear is a cell containing 2011 and MO is a cell containging 10. In this case it results in "October". But in the VBA module i just cannot get it to stop erroring out with the following message: COMPILE ERROR ...SYNTEX ERROR.

    Also this whole line is in red of code is in red.

    Can someone help me figure out why the code will not produce vMonth="October"?

    Thank you in advance.

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Convert two digit month (ex 10) to full Month Name in Variable

    Use FORMAT instead of TEXT.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Convert two digit month (ex 10) to full Month Name in Variable

    Use FORMAT instead of TEXT.

    Edit: and DATESERIAL instead of DATE:

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    10-08-2006
    Location
    Walnut, CA
    MS-Off Ver
    2003,2010, Office 365
    Posts
    114

    Re: Convert two digit month (ex 10) to full Month Name in Variable

    or
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    04-11-2013
    Location
    Las Vegas
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: Convert two digit month (ex 10) to full Month Name in Variable (SOLVED)

    Thank you Olly. You solved it. Worked like a charm.....much appreaciated.

  6. #6
    Registered User
    Join Date
    04-11-2013
    Location
    Las Vegas
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: Convert two digit month (ex 10) to full Month Name in Variable

    TonyS great answer ...thank you very much.

  7. #7
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Convert two digit month (ex 10) to full Month Name in Variable

    Quote Originally Posted by TonyS View Post
    or
    Please Login or Register  to view this content.
    That's nice I learned something new, thank you

    Is there an similarly simple inverse function, to convert month name to number?!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. how to convert the month in a date to the text word for that month
    By sthshrmags in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-05-2014, 03:15 PM
  2. Replies: 18
    Last Post: 09-08-2014, 05:06 PM
  3. [SOLVED] Excel 2007 : How to convert month number to month name
    By FDibbins in forum Excel General
    Replies: 14
    Last Post: 04-08-2014, 12:42 AM
  4. Convert date from current month to first day of prior month
    By maacmaac in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-07-2010, 12:23 PM
  5. how to convert single digit to month name
    By cygnus in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-27-2006, 05:40 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1