+ Reply to Thread
Results 1 to 7 of 7

Excel 2007: How to Convert "5/2/2013" to "May" then subtract a Month so it's "Apr"

  1. #1
    Registered User
    Join Date
    11-18-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    2

    Excel 2007: How to Convert "5/2/2013" to "May" then subtract a Month so it's "Apr"

    I'm trying to automate some reporting and our company has been doing this manually. I can't seem to find a automated way to convert a numerical date ("5/2/2013") to just the month "May", then subtract a month "Apr", so I can put it in for reporting for the previous month's data.

    Any ideas?

    Thanks in advance!!

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,739

    Re: Excel 2007: How to Convert "5/2/2013" to "May" then subtract a Month so it's "Apr"

    Assuming that date is in cell D2, then you could use this:

    =DATE(YEAR(D2),MONTH(D2)-1,DAY(D2))

    then apply a custom format to this cell of "mmm".

    Hope this helps.

    Pete

  3. #3
    Forum Expert ConneXionLost's Avatar
    Join Date
    03-11-2009
    Location
    Victoria, Canada
    MS-Off Ver
    2010
    Posts
    2,952

    Re: Excel 2007: How to Convert "5/2/2013" to "May" then subtract a Month so it's "Apr"

    Format both cells as, Custom "mmm" and use:

    Please Login or Register  to view this content.
    Would you like to say thanks? Please click the: " Add Reputation" button, on the grey bar below the post.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Excel 2007: How to Convert "5/2/2013" to "May" then subtract a Month so it's "Apr"

    To get the month name from a date you can use the worksheet function TEXT.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    In VBA you can use Format or MonthName with Month.

    Please Login or Register  to view this content.
    To get the previous month you can use EOMONTH worksheet function
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    In code you can use DateAdd.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  5. #5
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,739

    Re: Excel 2007: How to Convert "5/2/2013" to "May" then subtract a Month so it's "Apr"

    Another way (so you don't have to bother with formatting):

    =TEXT(DATE(YEAR(D2),MONTH(D2)-1,DAY(D2)),"mmm")

    Hope this helps.

    Pete

  6. #6
    Registered User
    Join Date
    11-18-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Excel 2007: How to Convert "5/2/2013" to "May" then subtract a Month so it's "Apr"

    Perfect, thanks!!!

  7. #7
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Excel 2007: How to Convert "5/2/2013" to "May" then subtract a Month so it's "Apr"

    Based on your last post in this thread, its apparent that you are satisfied with the solution(s) you've received and have solved your question, but you haven't marked your thread as "SOLVED". I will do it for you this time.

    In future, to mark your thread as Solved, you can do the following -
    Select Thread Tools-> Mark thread as Solved.

    Incase your issue is not solved, you can undo it as follows -
    Select Thread Tools-> Mark thread as Unsolved.

    Also, since you are relatively new to the forum, i would like to inform you that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post which helped you. This adds to the reputation of the person who has taken the time to help you.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ 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] Excel 2010 -- "Visual Basic" "Macros" and "Record Macro" all disabled.
    By NicholasL in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-07-2017, 06:11 AM
  2. Replies: 4
    Last Post: 11-17-2013, 12:05 PM
  3. [SOLVED] How to USE """"" cells count """"" change font color
    By austin123456 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-09-2013, 06:14 AM
  4. Replies: 3
    Last Post: 01-03-2013, 04:58 PM
  5. Replies: 7
    Last Post: 01-03-2013, 04:13 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