+ Reply to Thread
Results 1 to 3 of 3

Rename files based on excel worksheet list

  1. #1
    Registered User
    Join Date
    08-10-2009
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    2

    Rename files based on excel worksheet list

    Hi All,

    Really hoping you can help here.

    Each month I get a load of files which have been manually downloaded by someone else. This means that the convention is not always the same! However, there is always one part of the filename that is the same.

    EG: ABC 0455805919-062.csv will be downloaded the next month as GBV 0455805919-063.csv. The first part of the name will change, and the last part after the '-' increments by 1 each month.

    What i would like is some VBA to rename the files using a predetermined list.

    EG, always rename any file containing "0455805919" (the middle bit of the filename above) to fileone.csv

    I've played about with the 'name' option in VBA so I can rename files with , but am struggling with the changing filenames. Does anyone have any ideas that could help me? Sorry if I'm not being 100% clear!

    Thanks very much.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Rename files based on excel worksheet list

    Here are two macros to deal with both needs.

    The first creates the list of files for you in column A.
    The second renames the files based on the values in column B.

    The attached worksheet even offers a suggestion on making the conversion using a simple formula in B1 of:
    =IF(A1="", "", LOOKUP(MID(A1,FIND(" ",A1)+1,10),D:D,E:E ))

    A chart in column D:E with your search strings and your desired output filenames gives the formula what it needs to provide the answers.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    08-10-2009
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Rename files based on excel worksheet list

    Thanks for that, looks like exactly what i need! I'll give it a go tomorrow

+ 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