• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Macro to rename files

bnpdkh

Member
Hello, I am looking for a macro that will find a file based on cell value and remane that file based on another cell value. I use the code below to locate the file I want to rename. I then want to rename that file based on value incell I19 of the same sheet listed below.

Code:
Workbooks.Open(Filename:=Worksheets("Mechanical").Range("I11").Value _
        , UpdateLinks:=3)
 
Is something like as...

Code:
Option Explicit
Sub rename_()
Dim OldName As String, NewName As String, mydir As String

mydir = "C:\Users\dEEPAK\Desktop\"

With Worksheets("Mechanical")
    OldName = .Range("I11").Value
    NewName = .Range("I19").Value
End With

Name mydir & OldName As mydir & NewName

End Sub
 
Back
Top