PDA

View Full Version : [SOLVED:] Help with renaming files (Name "xxxxxxx" As "yyyyyyyy" wont work)



Johan90
05-07-2018, 06:24 AM
So as the title suggest I need help with renaming files. The Name As function I cant seem to get working for some reason


The macro will need to loop through two columns with old and new names, preferably I would like to have the old files deleted too.

I get the message box that all files have ben renamed succesfully.


This does nothing.

Sub RenameFiles()

Dim oldNa As String
Dim newNa As String


oldNa = Range("FO10")
newNa = Range("FP10")
Name oldNa As newNa


End Sub


So does this



Sub RenameFiles()

Name "C:\Users\xxxxxxx.AD\Desktop\Test\Vattenfall Invoice.txt" As "C:\Users\xxxxxx.AD\Desktop\Test\Vattenfall fakturorYYMM.txt"


End Sub

JKwan
05-07-2018, 06:34 AM
Well, your second example works for me. The only thing is that your "x" don't match.

Johan90
05-07-2018, 06:46 AM
Thanks for the confirmation, I found the problem, I hadnt selected the right macro for the button I was using. Stupid:banghead: