+ Reply to Thread
Results 1 to 14 of 14

Formual to Extract month and year from sheet name

  1. #1
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Formual to Extract month and year from sheet name

    Hello:

    I have a Monthly sheet tab Jan14,Feb14,Mar14, etc.

    I need a formula so in
    Jan14, I1=1, J1=2014
    Feb14, I1=2, J1=2014 and so on.

    please Let me know if you have any questions.
    Thanks.


    Riz

  2. #2
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: Formual to Extract month and year from sheet name

    In I1 (array formula)
    =MATCH(LEFT(MID(CELL("filename"),(FIND("]",CELL("filename"))+1),255),3),TEXT(DATE(YEAR(TODAY()),ROW(A1:A12),1),"mmm"),0)

    In J1
    =2000+RIGHT(MID(CELL("filename"),(FIND("]",CELL("filename"))+1),255),2)
    Life's a spreadsheet, Excel!
    Say thanks, Click *

  3. #3
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Formual to Extract month and year from sheet name

    Month
    =MONTH(I1)

    Year

    =YEAR(I1)

    I
    J
    K
    1
    14-Jan
    1
    2014
    2
    14-Feb
    2
    2014
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  4. #4
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: Formual to Extract month and year from sheet name

    Hi Ace_XL:

    It works, still need to know that you have "filename"..Where is that used.

    Works great
    Riz

  5. #5
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: Formual to Extract month and year from sheet name


  6. #6
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: Formual to Extract month and year from sheet name

    Hi Ace_XL:

    Seems to malfundtion.
    If i go to another monthly tab, then i see the same month as before.
    Please help.
    Thanks
    Riz

  7. #7
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: Formual to Extract month and year from sheet name

    Aah yes of course..Use this instead

    Array entered
    =MATCH(LEFT(MID(CELL("filename",A1),(FIND("]",CELL("filename",A1))+1),255),3),TEXT(DATE(YEAR(TODAY()),ROW(A1:A12),1),"mmm"),0)
    &
    =2000+RIGHT(MID(CELL("filename",A1),(FIND("]",CELL("filename",A1))+1),255),2)

    Alternatively, you could use a UDF to get sheetname and apply similar formulas. See here
    http://www.mrexcel.com/forum/excel-q...into-cell.html

  8. #8
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Formual to Extract month and year from sheet name

    Quote Originally Posted by Ace_XL View Post

    Array entered
    =MATCH(LEFT(MID(CELL("filename",A1),(FIND("]",CELL("filename",A1))+1),255),3),TEXT(DATE(YEAR(TODAY()),ROW(A1:A12),1),"mmm"),0)
    You can reduce that to:

    =MONTH(1&LEFT(MID(CELL("filename",A1),(FIND("]",CELL("filename",A1))+1),32),3))

    Normally entered.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  9. #9
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Formual to Extract month and year from sheet name

    =MONTH(1&REPLACE(CELL("filename",H1),1,FIND("]",CELL("filename",A1)),""))

    =YEAR(1&REPLACE(CELL("filename",H1),1,FIND("]",CELL("filename",A1)),""))

  10. #10
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: Formual to Extract month and year from sheet name

    Hi guys:

    I am still not sure where is the Sheet Name in the formula.
    I am seeing "filename" in the formula but what is that referring to.


    Would appreciate if someone can explain.
    Thanks
    Riz

  11. #11
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Formual to Extract month and year from sheet name

    The formulas are extracting the sheet name from the file name.

    In a file that has been saved and given a name enter this formula EXACTLY as shown in ANY cell:

    =CELL("filename",A1)

    Filename is the argument and is the information that the CELL function is going to return. "Filename" doesn't mean you're supposed to enter the filename!

    The formula returns the full path plus the file name and sheet name.

    So, the formula might return something like this:

    C:\A Excel Forum\[temp.xlsx]Jan14

    Then other parts of the formula extract the sheet name from that string.

  12. #12
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Formual to Extract month and year from sheet name

    Quote Originally Posted by Tony Valko View Post
    You can reduce that to:

    =MONTH(1&LEFT(MID(CELL("filename",A1),(FIND("]",CELL("filename",A1))+1),32),3))

    Normally entered.
    Improvement:

    =MONTH(1&MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,32))
    Last edited by Tony Valko; 07-26-2014 at 09:36 PM.

  13. #13
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: Formual to Extract month and year from sheet name

    Hello:
    Now I got it..working great
    Thanks
    Riz

  14. #14
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Formual to Extract month and year from sheet name

    Good deal. Thanks for the feedback!

+ 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. Extract data based on month/year to a simple table.
    By maax555 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-15-2014, 09:55 AM
  2. [SOLVED] formatting dates to automatically extract Year and month
    By alexcrofut in forum Excel General
    Replies: 1
    Last Post: 01-23-2014, 03:09 PM
  3. [SOLVED] Extract Year or Month only from a cell with date and time
    By djaurit in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-28-2013, 04:03 PM
  4. [SOLVED] Extract Text from String then Convert to a Date (Month/Year)
    By sgrey24 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-14-2013, 06:11 PM
  5. Replies: 1
    Last Post: 10-18-2012, 01:38 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