+ Reply to Thread
Results 1 to 4 of 4

filename last month

  1. #1
    Registered User
    Join Date
    09-10-2015
    Location
    London
    MS-Off Ver
    365 at work, 2016 at home
    Posts
    79

    filename last month

    Hi all,
    I'm trying to work with a file that's always a month behind.

    This works great for a file and location that's based on this month's name, but last month is a problem
    Please Login or Register  to view this content.
    the 17-18 in the path relates to the financial year, so will change, be great if we could automate that as well, but it's small enough to do this manually and leave it hard-coded

    Obviously, it's more complex in January, when the year needs to be behind as well.

    Google gave me this, but it's less than half the job.

    Please Login or Register  to view this content.
    also not sure how to tell LastMonth to not output the DD part since I only want Mmm YY

    Can anyone help me finish this off?
    thanks muchly
    Last edited by cheesemeister; 12-19-2017 at 10:39 AM. Reason: also need fpath

  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: filename last month

    Try:
    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
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,481

    Re: filename last month

    I'm not sure what you are looking for.

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    09-10-2015
    Location
    London
    MS-Off Ver
    365 at work, 2016 at home
    Posts
    79

    Re: filename last month

    Hi again,

    I'm nearly there
    Please Login or Register  to view this content.
    works fine apart from saving with the updated fname.

    The open file changes name on the title bar of the excel window, but doesn't save. In place of spaces between the words, it has %20 instead.
    Takes it's time to do it, excel crashed but recovered.

    I've used this line of code exactly as is before, so I'm stumped. (Different values for the variables, different project file so it's not a variable clash)
    Please Login or Register  to view this content.
    Similarly, I'm almost certain the ChDir is redundant, but it didn't want to work without it so...

    Lastly, the If Err doesn't do anything, doesn't give an error message, but the folder isn't created.
    Folder creation was working without the iferror, but if the folder's already in place and the code is just mkdir, then I get an error...
    Last edited by cheesemeister; 12-22-2017 at 09:45 AM. Reason: if err

+ 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. Need Macros to read excel filename based on Month name
    By Raj00786 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-26-2014, 10:50 AM
  2. [SOLVED] Macro to change month in filename
    By socrates18 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-19-2014, 04:03 AM
  3. Replacing specific characters of a filename every month. Please Help!!
    By rahulmamtora in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-27-2011, 10:35 PM
  4. Replacing specific characters of a filename every month
    By rahulmamtora in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-27-2011, 01:41 PM
  5. Add Previous Month to Filename
    By SAsplin in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-17-2011, 09:00 AM
  6. Filename as PRIOR month
    By hriggs in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-27-2008, 04:26 AM
  7. [SOLVED] How do I add a month to a filename extracted from a cell
    By Geoff in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-30-2006, 11:45 AM

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