+ Reply to Thread
Results 1 to 2 of 2

How Can The Macro Rename Files When The Original File Name Changes Everday

  1. #1
    Registered User
    Join Date
    08-17-2008
    Location
    London
    Posts
    18

    How Can The Macro Rename Files When The Original File Name Changes Everday

    Hi I'm quite new to Excel VBA so I'm having a bit of trouble with the codes that Excel uses but I know the overall steps of my program and the logic behind it. I would be greatful if someone could guide me on this.

    - Suppose I have a folder with a list of 3 files, updated daily.

    - The 3 files are updated daily and named according to the current date. So for example, if it was Tuesday 28 July, the three files would be named:
    HOJ_20080728.xls
    UUL_20080728.xls
    QWK_20080728.xls

    If the date was September 29 2008 the files would be named:
    HOJ_20080929.xls
    UUL_20080929.xls
    QWK_20080929.xls

    and so on..


    - Now, I need my program to convert the files to a different name:
    For the "HOJ_date" file, the name needs to change to H11A.csv
    For the "UUL_date" file, the name needs to change to U22A.csv
    For the "QWK_date" file, the name needs to change 2 Q33A.csv

    This may seem easy but the problem is that the name of the original files change everyday because of the date.

    So I need the program to be able to change the file names to the ones I specified above everday, regardless of the fact that the date changes.

    I kind of have a "half-solution" but I'm not too familiar with the VBA terminology for codes so I will just list the overall kind of logic.
    -------------------------------------------------------------------------
    Suppose today is 15 March 2008, then:

    -------------------------------------------------------------------------
    Please Login or Register  to view this content.
    -------------------------------------------------------------------------

    So that's the overall logic I wanted to implement.
    The program gets all the files from the folder and opens them one by one and saves a CSV version with new names.

    Do you think this may be possible?

    Please do help me.

    - The only hard thing I reckon is the fact that I don't know whether you can just open any file from the folder, in any order you want and then change the filename. And then open any other file you wish. Do you see what I mean?

    I would greatly appreciate your help.

    Many thanks.

    P.S this is getting quite long for me so if someone could get a solution then I would be over the moon and really greatful to you!
    Last edited by np123345; 09-01-2008 at 05:44 PM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464
    Hi,

    This is untested - (which I usually like to do before posting) since it uses the File System object, and unfortunately the version of Excel for the Mac, which I'm using at the moment, does not support this syntax. However I hope it gives you the general idea.

    Please Login or Register  to view this content.
    Last edited by Richard Buttrey; 09-01-2008 at 07:03 PM.

+ 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. Replies: 14
    Last Post: 04-17-2008, 04:12 PM
  2. Macro - Collect data - Select folder and loop through all xls files
    By kostas in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-04-2008, 05:58 AM
  3. vba to change macro file name
    By blackstar in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-02-2007, 12:14 AM
  4. Summarize results from files into main file
    By aktarina in forum Excel General
    Replies: 4
    Last Post: 09-06-2007, 01:09 AM
  5. Macro to change file types
    By erock24 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-10-2007, 05:50 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