KlausW
Active Member
- Joined
- Sep 9, 2020
- Messages
- 453
- Office Version
- 2016
- Platform
- Windows
Hi
I use this VBA code to rename images and it works well.
I have done something so that the text in column D, new image name cannot be recognised. And I for the following error message.
I can't figure out how to format the cells in column D so that the VBA code can use them.
Anyone who can help?
Any help will be appreciated.
Best regards
Klaus W
File for help
I use this VBA code to rename images and it works well.
I have done something so that the text in column D, new image name cannot be recognised. And I for the following error message.
I can't figure out how to format the cells in column D so that the VBA code can use them.
Anyone who can help?
Any help will be appreciated.
Best regards
Klaus W
File for help
VBA Code:
Sub Rektangelafrundedehjørner1773_Klik()
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Ark1")
Dim fso As New FileSystemObject
Dim fo As Folder
Dim f As File
Dim new_name As String
Set fo = fso.GetFolder(sh.Range("e1").Value)
For Each f In fo.Files
new_name = Application.VLookup(f.Name, sh.Range("A:d"), 4, 0)
f.Name = new_name
Next
MsgBox "Done"
End Sub