+ Reply to Thread
Results 1 to 9 of 9

Formula or VB Cdoe to get Month and Year from Long date range

  1. #1
    Forum Contributor
    Join Date
    01-31-2012
    Location
    Georgia
    MS-Off Ver
    Excel 2010
    Posts
    193

    Formula or VB Cdoe to get Month and Year from Long date range

    Hello:
    I have F5="Tuesday, June 1, 2021 - Wednesday, June 30, 2021"

    I need Excel formula or VB Code to get N1=MM-YYYY so N1=06-2021

    Please let me know if you have any questions.
    Thanks.

    Riz

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,529

    Re: Formula or VB Cdoe to get Month and Year from Long date range

    To get the first date, use:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Format as "mm-yyyy".
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2016 & H&B2021
    Posts
    3,069

    Re: Formula or VB Cdoe to get Month and Year from Long date range

    Try this, N1: =DATEVALUE(MID(F5,FIND(",",F5)+2,3)&"-"&RIGHT(F5,4))

  4. #4
    Forum Contributor
    Join Date
    01-31-2012
    Location
    Georgia
    MS-Off Ver
    Excel 2010
    Posts
    193

    Re: Formula or VB Cdoe to get Month and Year from Long date range

    Hello:

    I need to use above to put in VB Code

    Range("N1").Formula = "=datevalue(mid(f5,find(",",f5)+2,3)&"-"&right(f5,4))"

    Its giving error.

    Can you please with it.

    R

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,529

    Re: Formula or VB Cdoe to get Month and Year from Long date range

    Double up the quotes.

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,529

    Re: Formula or VB Cdoe to get Month and Year from Long date range

    Try:
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    01-31-2012
    Location
    Georgia
    MS-Off Ver
    Excel 2010
    Posts
    193

    Re: Formula or VB Cdoe to get Month and Year from Long date range

    Hello:

    Thanks TMS and joseph

    Works for me.

    R

  8. #8
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2016 & H&B2021
    Posts
    3,069

    Re: Formula or VB Cdoe to get Month and Year from Long date range

    If the text in F5 is enclosed with double-quotes, then =DATEVALUE(MID(F5,FIND(",",F5)+2,3)&" - "&MID(F5,FIND(" -",F5)-4,4)).

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,529

    Re: Formula or VB Cdoe to get Month and Year from Long date range

    You're welcome. Thanks for the rep.

+ 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. Extracting Date (year,month,day) from cell with Date (year,month,day,time)
    By TheRobsterUK in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-16-2020, 01:58 PM
  2. Replies: 3
    Last Post: 06-26-2019, 11:46 AM
  3. Replies: 9
    Last Post: 10-08-2015, 01:50 PM
  4. [SOLVED] Look up month and year value using ID # and date (within a range)
    By ryanpetersen in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-28-2014, 02:17 AM
  5. Need to convert Month/Date/Year to Year/Month/Date so excel will recognize
    By juliettelam in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-25-2014, 04:17 PM
  6. Macro or Formula to create Date range by getting input of month and year
    By indianhp in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-03-2013, 11:00 AM
  7. formula for prior month & year of a month end date.
    By mikeburg in forum Excel General
    Replies: 2
    Last Post: 09-25-2007, 04:01 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