excelvba

Edit links to a new month's file


I have a checks file that brings in data from several other files to perform various checks. Every month, I copy last month's check file, copy it into a new folder, and edit links to the new month.

Could I find last month's links by using "*NYC*" and replace with this month's NYC file? Or something along those lines?

There are 10ish links in the file and none will have a duplicate city name, but they all have the same name up to their city suffix.

In short, I think what I would like to do is replace the "*... - NY" link with something like ThisWorkbook.Path & "* - NY"


Solution

  • Thank you for the responses. I took a different approach that worked for me. I used a formula in the checking file to get the old file paths which allowed me to do the following:

    Dim OldNYCLink As String
    Dim NewNYCLink As String
    OldNYCLink = Range("E51")
    NewNYCLink = Left(ThisWorkbook.FullName, Len(ThisWorkbook.FullName) - 5) & " - NYC.xlsm"
    
    Dim OldBostonLink As String
    Dim NewBostonLink As String
    OldBostonLink = Range("F51")
    NewBostonLink = Left(ThisWorkbook.FullName, Len(ThisWorkbook.FullName) - 5) & " - Boston.xlsm"