Renaming Multiple PDF Files in folder using excel

JM1982

New Member
Joined
Jun 17, 2018
Messages
1
Hi to everybody..

I'm renaming my pdf files in one folder from the excel sheet list which my PDF filename are drawing number only but I want to add in my pdf filename the drawing title which is in the excel sheet. So I made this vba code but now its not wor
What is the wrong in my vba code, i'm getting run time error 5. The vba code is look like this.

Sub ChangeInFolder()
Dim OldName As String
Dim NewName As String
Dim LastRow As Long
Dim i As Long
LastRow = Range("A65536").End(xlUp).Row

For i = 11 To LastRow
OldName = Range("A" & i).Value
NewName = Range("C" & i).Value



' OldName = "\\172.16.95.58\Finance-BackOffice\Bank Statement\Supporting\" + Range("A" & i).Value + ".pdf"
' NewName = "\\172.16.95.58\Finance-BackOffice\Bank Statement\Supporting\" + Range("C" & i).Value + ".pdf"


Name OldName As NewName
Next i
Range("C2", Range("C2").End(xlDown)).ClearContents
Application.ScreenUpdating = True
End Sub
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Not quite sure why you've commented out the version with the full path, but the way you're joining the strings together there doesn't look right. Should be;

Code:
OldName = "\\172.16.95.58\Finance-BackOffice\Bank Statement\Supporting\" & Range("A" & i).Value & ".pdf"

Using "&" and not "+"

Does that help any?
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top