+ Reply to Thread
Results 1 to 11 of 11

Find Month Name

  1. #1
    Registered User
    Join Date
    12-17-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    45

    Find Month Name

    Hello Forum,

    I am trying to identify month and year from a date in generic format so that :
    1. The month value be changed to the name of the month.
    2. Identify the last two digit values of the year.
    3. Concatenate first 3 characters of month name, a hyphen and last 2 digits of year.

    Please go through the attachment. MonthYear.xlsx. Column B is the function output.

    Wrote a function for this purpose, but it is not working properly in some cases. Please go through the code:
    Please Login or Register  to view this content.
    Regards,
    Sailaja

  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: Find Month Name

    Why not just use formula:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    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
    Registered User
    Join Date
    12-17-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    45

    Re: Find Month Name

    Hello OllyXLS,

    Tried TEXT() function also. But it also not working for all cases.

    Please go through the attachment. Column C displays Text() function output. MonthYear.xlsx

    Regards,
    Sailaja

  4. #4
    Registered User
    Join Date
    08-14-2013
    Location
    Arizona
    MS-Off Ver
    Excel 2007
    Posts
    71

    Re: Find Month Name

    Change col A to mm/dd/yyyy instead of dd/mm/yyyy. Excel reads it as mm/dd, note how A10 is 5/11, excel thinks it's May 11.

  5. #5
    Registered User
    Join Date
    12-17-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    45

    Re: Find Month Name

    Hello jwlamb,

    I changed the Date format also. I am still getting the same old result given by Text() function.

    Regards,
    Sailaja

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

    Re: Find Month Name

    When I open your attachment, the TEXT formula in Column C seems to work perfectly. This is what I see:

    A
    B
    C
    1
    31/10/2012
    Oct-12 Oct-12
    2
    30/10/2012
    #NAME?
    Oct-12
    3
    30/10/2012
    #NAME?
    Oct-12
    4
    11/01/2012
    #NAME?
    Jan-12
    5
    11/09/2012
    #NAME?
    Sep-12
    6
    21/11/2012
    #NAME?
    Nov-12
    7
    11/12/2012
    #NAME?
    Dec-12
    8
    21/09/2012
    #NAME?
    Sep-12
    9
    23/11/2012
    #NAME?
    Nov-12
    10
    11/05/2012
    #NAME?
    May-12
    11
    19/11/2012
    #NAME?
    Nov-12
    12
    14/12/2012
    #NAME?
    Dec-12
    13
    29/11/2012
    #NAME?
    Nov-12
    14
    12/10/2012
    #NAME?
    Oct-12
    15
    12/06/2012
    #NAME?
    Jun-12
    16
    11/09/2012
    #NAME?
    Sep-12
    17
    15/10/2012
    #NAME?
    Oct-12
    18
    12/03/2012
    #NAME?
    Mar-12
    19
    01/07/2013
    #NAME?
    Jul-13
    20
    29/11/2012
    #NAME?
    Nov-12


    Obviously the UDF fails, as you've uploaded a .XLSX file, with no code in it...

  7. #7
    Registered User
    Join Date
    12-17-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    45

    Re: Find Month Name

    You are right OllyXLS regarding UDF. I uploaded a non macro file.

    Coming to Column C : Have you changed the format of the data in the column or it is showing the result as it is. I am not understanding where I am making the mistake.

  8. #8
    Registered User
    Join Date
    12-17-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    45

    Re: Find Month Name

    I am uploading a macro enabled (.xlms) file MonthYear.xlsm
    Column D is the changed format of Column A to Date (US Date format mm/dd/yyyy).

  9. #9
    Forum Contributor
    Join Date
    12-09-2013
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    171

    Re: Find Month Name

    Hi Sailaja,

    As per your file, Column A contains date in "Date" format, Not in String/Text format. Hence the months <10 in the sheet may appear with "0" Prefix (Ex. 01,02,03...09)

    But, in actual it will store as numbers only. So, in your switch case you need to refer them as numbers (without zero prefix).

    And convert the month and year to Value through function Val()

    m=val(mid(d,4,2))

    Your problem can solved in two ways (as said in old posts).

    =Text(date(Year(A1),Month(A1),Day(A1)),"Mmm-YY)

    the above will doesn't mater about the system date format.

    and the second one will be the UDF you written and again you are thinking that date is in DD/MM/YYYY format.

    Thanks,
    Bhanu

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

    Re: Find Month Name

    It still works perfectly for me, without changing anything - this is exactly what I see when I open your latest attachment:

    A
    B
    C
    1
    31/10/2012
    Oct-12 Oct-12
    2
    30/10/2012
    Oct-12 Oct-12
    3
    30/10/2012
    Oct-12 Oct-12
    4
    11/01/2012
    Jan-12 Jan-12
    5
    11/09/2012
    Sep-12 Sep-12
    6
    21/11/2012
    Nov-12 Nov-12
    7
    11/12/2012
    Dec-12 Dec-12
    8
    21/09/2012
    Sep-12 Sep-12
    9
    23/11/2012
    Nov-12 Nov-12
    10
    11/05/2012
    May-12 May-12
    11
    19/11/2012
    Nov-12 Nov-12
    12
    14/12/2012
    Dec-12 Dec-12
    13
    29/11/2012
    Nov-12 Nov-12
    14
    12/10/2012
    Oct-12 Oct-12
    15
    12/06/2012
    Jun-12 Jun-12
    16
    11/09/2012
    Sep-12 Sep-12
    17
    15/10/2012
    Oct-12 Oct-12
    18
    12/03/2012
    Mar-12 Mar-12
    19
    01/07/2013
    Jul-13 Jul-13
    20
    29/11/2012
    Nov-12 Nov-12


    So, I'm unable to provide any further help, as I can't see the problem!

  11. #11
    Forum Contributor
    Join Date
    12-09-2013
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    171

    Re: Find Month Name

    Hi Sailaja,

    Please find the attached updated file with corrected code.

    Thanks,
    Bhanu
    Attached Files Attached Files

+ 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. [SOLVED] Find First, Max, Min, Last value of a month of an year
    By TK2013 in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 08-26-2013, 07:19 PM
  2. Find max value and return associated month
    By daveeeeT in forum Excel General
    Replies: 3
    Last Post: 03-02-2012, 03:52 PM
  3. Replies: 10
    Last Post: 01-22-2012, 10:05 AM
  4. How to find the next business day after the last day of the month.
    By mto@hodes.com in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-07-2008, 12:32 PM
  5. How do i find the first value every month
    By pex in forum Excel General
    Replies: 1
    Last Post: 10-06-2005, 02:05 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