+ Reply to Thread
Results 1 to 5 of 5

File Renamer VBA

  1. #1
    Registered User
    Join Date
    04-03-2022
    Location
    London, England
    MS-Off Ver
    Ms. Office 2013
    Posts
    79

    File Renamer VBA

    Hi all, so I want to automatically rename multiple files through a button in VBA but I don't really know how the logic is...

    I plan to put all files I want to rename in a single folder, so I think it would be best to use FileDialog(msoFileDialogFolderPicker) to pick the folder.

    I've attached the example names of the original file and the file name I want them to be renamed in the attachment. The original names are in column A, while the renamed names should be the column B. The columns could be edited in the future so I think it would be better to refer to the columns.

    Can anyone help me on this?

    Thank you!
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Question Re: File Renamer VBA


    Hi,

    is it normal any file has an extension ?

  3. #3
    Registered User
    Join Date
    04-03-2022
    Location
    London, England
    MS-Off Ver
    Ms. Office 2013
    Posts
    79

    Re: File Renamer VBA

    Oh, Hi Marc L! Thank you for replying

    All files are .xlsx format

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Try this !


    According to your attachment a VBA demonstration for starters :

    PHP Code: 
    Sub Demo1()
            
    R& = [A1].CurrentRegion.Rows.Count:  If 1 Then Exit Sub
        With Application
    .FileDialog(4)
            If .
    Show Then V = .SelectedItems(1) & Application.PathSeparator Else Exit Sub
        End With
            V 
    Evaluate("""" """&A2:B" "&"".xlsx""")
        For 
    1 To R 1
            
    If Dir(V(R1)) > "" Then If Dir(V(R2)) = "" Then Name V(R1) As V(R2)
        
    Next
    End Sub 
    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !

  5. #5
    Registered User
    Join Date
    04-03-2022
    Location
    London, England
    MS-Off Ver
    Ms. Office 2013
    Posts
    79

    Re: Try this !

    Hi Marc L, the code works wonders!

    Thank you so much! I hope you have a great day!

+ 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: 8
    Last Post: 12-23-2022, 04:09 AM
  2. Replies: 5
    Last Post: 12-23-2022, 04:02 AM
  3. File Renamer skipping over part of macro
    By jomili in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-27-2019, 03:40 PM
  4. Bulk file renamer required.
    By X82 in forum Excel Programming / VBA / Macros
    Replies: 25
    Last Post: 09-15-2017, 01:15 PM
  5. Save as macro that specifies file type, file location and takes file name from three cells
    By ExcelFailure in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 06-13-2013, 10:09 PM
  6. Open 2nd file(CSV) from cell reference, copy columns to main file & close 2nd file
    By Langchop in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-31-2013, 05:09 AM
  7. How to: Open file, format data, save file, close file and repeat.
    By thexeber in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-11-2010, 12:56 PM

Tags for this Thread

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