+ Reply to Thread
Results 1 to 6 of 6

Code to generate File Name

  1. #1
    Forum Contributor
    Join Date
    12-14-2005
    Location
    US
    MS-Off Ver
    Excel 2019, Excel 365, Excel Mobile (Android)
    Posts
    145

    Code to generate File Name

    I presently have code that copies information from one workbook sheet and paste it into a different workbook. Part of the code is:
    Please Login or Register  to view this content.
    The code works fine, each year I change the year and each month change the month so the information goes into the correct file and sheet month.

    What I would like to do is develop code that would automatically generate the file name as it appears above and the sheet name so the information can then be pasted in the correct fie and sheet. With that in mine, I have added a sheet called TABLES and added the following information;

    B1 text =C:\User\Fis\ACCT\AGENT\DAILY\
    B2 text = DATA -
    B3 formula =YEAR(TODAY()) which returns 2023
    B4 formula =MONTH(TODAY()) which returns 10 but the cell is custom formatted to MMM (OCT)[HTML]

    Hopefully, it can be done, especially getting the month correct as text (Jan, Feb etc) instead of (1, 2, 3) so it matches up with the text named sheets.

    As always thanks for any help provded.

  2. #2
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Code to generate File Name

    Why not have it take the month number and lookup the words Jan, Feb etc. and return those.
    1 Jan
    2 Feb
    You could use index match or vlookup.
    Click the * Add Reputation button in the lower left hand corner of this post to say thanks.

    Don't forget to mark this thread SOLVED by going to the "Thread Tools" drop down list above your first post and choosing solved.

  3. #3
    Forum Expert
    Join Date
    10-11-2021
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    1,386

    Re: Code to generate File Name

    Please Login or Register  to view this content.
    This also returns "oct"

    Please Login or Register  to view this content.
    Last edited by JEC.; 10-30-2023 at 03:04 PM.

  4. #4
    Registered User
    Join Date
    10-16-2023
    Location
    Poland
    MS-Off Ver
    Excel 2019 32bit WIN10
    Posts
    88

    Re: Code to generate File Name

    Check this:
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    12-14-2005
    Location
    US
    MS-Off Ver
    Excel 2019, Excel 365, Excel Mobile (Android)
    Posts
    145

    Re: Code to generate File Name

    I have attached a worksheet for reference. I have tried the suggested code provided above, but it failed to work. It stopped when evaluating the code for setting the file name.
    Hopefully with the attached worksheet it can be adjusted so as to work as expected.

    Thank you all for your assistance.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    10-16-2023
    Location
    Poland
    MS-Off Ver
    Excel 2019 32bit WIN10
    Posts
    88

    Re: Code to generate File Name

    No space and dash after "TEST1"?:
    Please Login or Register  to view this content.
    Last edited by Tajan; 10-31-2023 at 11:25 AM.

+ 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] Generate new name of file based on Original file name
    By jimjones1958 in forum Excel General
    Replies: 5
    Last Post: 11-09-2021, 03:46 PM
  2. Replies: 1
    Last Post: 02-24-2018, 10:56 AM
  3. [SOLVED] Generate random Code consist of number and letter using VBA code
    By mazan2010 in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 06-27-2017, 11:03 AM
  4. How can I generate a Word file using an Excel file?
    By public in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 07-07-2015, 05:46 AM
  5. Replies: 4
    Last Post: 05-30-2015, 01:09 PM
  6. [SOLVED] Need VBA Help on MS-Access to generate report & save to xlsb file to tageted file
    By breadwinner in forum Access Programming / VBA / Macros
    Replies: 6
    Last Post: 05-23-2014, 07:52 AM
  7. Dynamically Generate graph in an excel file from a .csv file [URGENT]
    By pushkarjajoria in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-14-2013, 06:51 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