+ Reply to Thread
Results 1 to 5 of 5

Rename Part of All Files in Folder

  1. #1
    Registered User
    Join Date
    03-03-2010
    Location
    Orlando, Florida
    MS-Off Ver
    Excel 2007
    Posts
    48

    Rename Part of All Files in Folder

    I'm having trouble changing part of the file name for all the files in a particular folder. What I want to do is have an Input Box appear that I can input the current week. The macro will then find last week's number in the file name and replace it with the current number. The part I'm having trouble with is all the file names are slightly different. Here are file names: Week 21 Monday.xls, Week 21 Tuesday.xls, etc. for each day of the week.

    I need a macro to change the numerical part of the file only with the number I input into the Input Box. Any help is greatly appreciated. I'm really close, but I cannot get this last part to work.
    Last edited by fervorking; 05-24-2011 at 06:09 PM.

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Rename Part of All Files in Folder

    http://www.codejacked.com/renaming-m...-once-windows/ or
    http://dos.software.informer.com/dow...ing-wildcards/
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Rename Part of All Files in Folder

    You can use the Replace function for that. It'd be something like this, looped over each file name:

    Please Login or Register  to view this content.
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  4. #4
    Registered User
    Join Date
    03-03-2010
    Location
    Orlando, Florida
    MS-Off Ver
    Excel 2007
    Posts
    48

    Re: Rename Part of All Files in Folder

    Quote Originally Posted by davegugg View Post
    You can use the Replace function for that. It'd be something like this, looped over each file name:

    Please Login or Register  to view this content.
    How would I do that? I only know For-Next loops (pretty new to VBA).

  5. #5
    Registered User
    Join Date
    03-03-2010
    Location
    Orlando, Florida
    MS-Off Ver
    Excel 2007
    Posts
    48

    Re: Rename Part of All Files in Folder

    Nevermind. I figured it out using a Do While. Thanks for the help.

+ 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