Consulting

Results 1 to 2 of 2

Thread: Select Folder and Rename Files according to list in excel using VBA

  1. #1

    Select Folder and Rename Files according to list in excel using VBA

    Hello vba gurus. I have a list of names in an excel file in Column A. I have a group of folders with files in them. I want the files to be renamed according to the list in Column A. The next folder will begin when the names have "break" in the row.
    Please find below an example.
    In the below scenario, I will have 3 folders.
    Folder 1 will have 3 files, Folder 2 will have 5 files and Folder will have 5 files.
    The files will have random names and the folders and files will be sorted by name.
    I want the code to read column A and ask me to select folder. It should then rename the files in the folder that I have selected according to column A.
    When it reads "break", it should ask me to select folder again. It should then read the names and rename the files in that folder accordingly.
    When it reads break again, it should ask me to select folder and so on.
    The number of names in the excel file and the corresponding files will always be same. the code should only change the name of the file, the extension should remain the same.
    Appreciate your kind help.

    Column A
    Hello
    world
    How
    break
    are
    you
    wassup
    good
    bye
    break
    tomorrow
    is
    a
    new
    day

    I apologize if I have made an error in not following the posting rules. I am quite new to vba and to this forum so please excuse my noon-ness.

  2. #2
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    welcome to the forum.

    post your workbook pls

    clearly define the requirement
    what are old file names and what will new file names be
    how do we match old and new names.

    etc, etc...
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •