Look for a match for external file and rename it in vba


New Member
Jun 6, 2013
Hello all:
I have run into a problem that I was given a list of file names in the spread sheet, and I will need to look for all files(located where else in a shared drive) with the name that match the first six character in the file names given in the spread sheet, and rename all that files to some other names given in the same spread sheet, and kill all the origional files. Getting really frustrated here.:confused: I will value and appreciate your help. Thanks in advance.


Well-known Member
May 19, 2002
Welcome to MrExcel board....

give some examples of file names to find and what to be renamed. Where are the files to be saved? in the same location? Are all the files in the same directory?


New Member
Jun 6, 2013
Example: I want to perform the following task
Given a folder on the desktop with numbers of pdf files in it as (274283.1.pdf 274284.8 pdf ....) In the Spred sheet we have the following:
Drawing numbers ................................Finalized drawing names
274283..............................................274283 230KV.45kv. 6R
274284..............................................274284 230KV. sw swt 4R11

what i want to do is If the first six digits of the pdf file match the drawing number, then we rename that pdf file used the finalized name crosponding to that drawing number but still in pdf form in the same folder where the old ones at, there may be 400 or more pdf files in the folder.

Thanks for your help
Last edited:

Forum statistics

Latest member
Ben Morgan 1985

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...