+ Reply to Thread
Results 1 to 3 of 3

Generate File Name Programatically

  1. #1
    Registered User
    Join Date
    07-06-2009
    Location
    NH, USA
    MS-Off Ver
    2010 & 2013
    Posts
    38

    Question Generate File Name Programatically

    I have a series of files, all named sequentially by date, for example...

    Sales Report - Week of 2009-07-27 - NH.xlsm
    Sales Report - Week of 2009-08-03 - NH.xlsm
    Sales Report - Week of 2009-08-10 - NH.xlsm

    ...and so on. (The dates are always Mondays.)

    I want to get the contents of a particular range on the previous file (e.g. the "RaceResults" range a.k.a. B4:B33 on "Sales Report - Week of 2009-08-10 - NH.xlsm")

    Right now, I've got the following fairly inelegant code that mostly gets the job done.

    Please Login or Register  to view this content.
    Obviously, the problem is the first line. I always want to grab data from the week before, but how do I generate the file name?

    (If anybody knows a good way to manipulate the entire range at once - rather than all that FillDown/Copy/PasteSpecial nonsense - I'm game to hear that, too.)
    Last edited by T.J. Lanza; 08-19-2009 at 02:12 PM. Reason: Solved!

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887

    Re: Generate File Name Programatically

    Hi Timothy, and welcome to the forum.

    The code below will open the previous Monday's workbook, copy the range, paste it to the current workbook and then close last week's. You shouldn't see it happen as I've set ScreenUpdating to False at the beginning of the macro.
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    07-06-2009
    Location
    NH, USA
    MS-Off Ver
    2010 & 2013
    Posts
    38

    Thumbs up Re: Generate File Name Programatically

    Thank you very much! I took a little tweaking, but it worked perfect. Only thing I need to change was slipping PasteSpecial back in.

    And I learned something new... I like the Application.ScreenUpdating = False bit.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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