I have an excel file which consists of old name and new name in two different columns. I have 500 photos in a folder. I want to rename the photos with the new names when there is a match with the old name(same as that of image name) in the excel.
I have an excel file which consists of old name and new name in two different columns. I have 500 photos in a folder. I want to rename the photos with the new names when there is a match with the old name(same as that of image name) in the excel.
Hi, dvnr_76,
there´s a little bit more that you need to consider than just giving up the name of the files: you could give some information about the folder or the extension of the images. Please adjust the constants to suit:
Please Login or Register to view this content.
Ciao,How to install your new code
- Copy the Excel VBA code
- Select the workbook in which you want to store the Excel VBA code
- Press Alt+F11 to open the Visual Basic Editor
- Choose Insert > Module
- Edit > Paste the macro into the module that appeared
- Close the VBEditor
- Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)
To run the Excel VBA code:
- Press Alt-F8 to open the macro list
- Select a macro in the list
- Click the Run button
Holger
Use Code-Tags for showing your code: [code] Your Code here [/code]
Please mark your question Solved if there has been offered a solution that works fine for you
Dear ciao thanks a lot.. but i am unable to update... i tried the following
Sub EF973849()
Dim lngCounter As Long
Const cstrFOLDER As String = "C:\Users\nagaraju\Desktop\I IT Photos"
Const cstrSHEET As String = "Sheet1"
Const cstrEXTENS As String = ".JPG"
With Sheets(cstrSHEET)
For lngCounter = 2 To .Range("A" & Rows.Count).End(xlUp).Row
If Len(Dir(cstrFOLDER & .Cells(lngCounter, "A").Value & cstrEXTENS)) > 0 Then
Name (cstrFOLDER & .Cells(lngCounter, "A").Value & cstrEXTENS) As (cstrFOLDER & .Cells(lngCounter, "B").Value & cstrEXTENS)
End If
Next lngCounter
End With
End Sub
Hi, dvnr_76,
you would need to rap your code with code-tags according to Forum Rule #3.
Your code
is missing the last backslash as shown in my example.Please Login or Register to view this content.
Ciao,
Holger
Wow u r brilliant... it helped me lot... thnak you very much..
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks