Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Office 365. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Updating Links in Copied Files.

Updating Links in Copied Files

by Allen Wyatt
(last updated October 30, 2020)

5

Let's say you have two workbooks that you use for tracking sales in the current month, 2020JuneA.xls and 2020JuneB.xls, and that 2020JuneA.xls contains links to data in 2020JuneB.xls. When it comes time to copy the workbooks for the new month, you may be wondering about the best way to update all the links in the first workbook so they point to the second workbook for the new month.

To prepare workbooks for the new month, most people will open a Windows folder and copy the workbook files within Windows, not even in Excel. This, however, is the way to guarantee that you do the most work in updating the files. A simpler way is to bypass Windows and do the saving in Excel. Follow these general steps:

  1. Open both 2020JuneA.xls and 2020JuneB.xls in Excel.
  2. Use Save As to save the 2020JuneB.xls file under the name 2020JulyB.xls.
  3. Use Save As to save the 2020Junexls file under the name 2020JulyA.xls.

As part of saving out 2020JulyB.xls (step 2), Excel automatically updates all the links in 2020JuneA.xls so that they point to the new file name. When you then save 2020JulyA.xls (step 3), you complete the cycle and end up with the new workbooks for the new month, with the past month's files still secure on disk.

If saving the files under new names in Excel is not possible for some reason (perhaps someone else already made a copy of the workbook for the new month and made changes in the file) then you will need to resort to doing some manual editing of the links. Fortunately you can use the Find and Replace features of Excel to help in this task:

  1. Open the 2020JulyA.xls file.
  2. Press Ctrl+H to display the Replace tab of the Find and Replace dialog box. (See Figure 1.)
  3. Figure 1. The Replace tab of the Find and Replace dialog box.

  4. In the Find What box, enter the root portion of the old worksheet name (2020JuneB).
  5. In the Replace With box, enter the root portion of the new worksheet name (2020JulyB).
  6. Click Replace All.

Excel goes through the entire worksheet—including the links—and makes changes to the appropriate text.

Another approach is to deal with your monthly files as a whole. In other words, don't have the filenames reflect the month, but put all the workbooks for the month in a single folder that is named after the month. Under this scenario, you could have a June folder, and then make a copy of the whole folder and name it July. You would then have duplicate copies of the workbooks in separate folders. You could work with them independently, as long as you don't try to open the same workbook from both months at the same time. (Excel won't allow you to open multiple workbooks with the same name.)

If you want to make your linking strategy more flexible, you can always use the INDIRECT function. For instance, suppose that your link is something like this:

=[2020JuneB.xls]Sheet1!B3

You could put the name of the source file (2020JuneB.xls) in a cell in the current worksheet (D5, for example) and replace the above expression with one like this:

=INDIRECT("'[" & D5 & "']Sheet1!B3")

Changing the contents of cell D5 to a different filename will make that file the new source of data. There are a couple of "gottchas," however. First of all, you need to manually open the file that is the target of the link; Excel won't do it for you as it would with a regular link. Also, workbook filenames that contain spaces will trip up the INDIRECT formula. If you think you might have spaces in your filenames, you should change the formula to this:

=INDIRECT("['" & D5 & "]Sheet1'!B3")

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (11027) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Office 365. You can find a version of this tip for the older menu interface of Excel here: Updating Links in Copied Files.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Toggling AutoFilter

Want a tool that will help you toggle AutoFilter on and off? Excel provides some tools you can use, but you need to be ...

Discover More

Adding Captions

Need to add a caption after a document element such as a figure or table? You can add and format one manually, or you can ...

Discover More

Thoughts and Ideas on Significant Digits in Excel

Ruminations and reflections about significant digits in Excel. Includes examples of how significant digits can affect the ...

Discover More

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

More ExcelTips (ribbon)

Tying a Hyperlink to a Specific Cell

Make a hyperlink to a cell in your workbook, edit the structure of that workbook a bit, and you may find that the ...

Discover More

Jumping to a Specific Cell Using a Hyperlink

Excel allows you to define hyperlinks in your worksheets, and these can target specific cells on other worksheets. Here ...

Discover More

Changing Link References

If you use UNC paths in your links to external information, those paths may need to be changed at some point. You can ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is five more than 5?

2020-11-02 04:27:17

Col Delane

Depending on what folder structure the linked files are saved in, unless something has recently changed in Excel, this tip is bunkum!

Lets say two files (2020JuneA.xls and 2020JuneB.xls are linked as described in the tip) and are saved in the same folder (e.g. June 2020) under a higher level folder named "Sales". If you use Windows to create a new sub-folder under Sales called July 2020, and then copy all files in the June 2020 folder and paste them into July 2020, the links between the two files will remain intact.
If you then use Excel to open the two files in the July 2020 folder, the links in the dependent file (2020JuneA.xls) will be to 2020JuneB.xls in the July 2020 folder (it works a bit like a relative reference - the link is to another file in the same folder rather than a file in a prescribed "hard coded" folder).
Sure the filenames do not match the new folder, but that's why you use generic filenames and let the folder name identify the contents, otherwise you're just duplicating the month in both filename and folder.


2020-11-01 22:08:21

Neil

A much easier way to change all the links instead of using Find and Replace is to use the menu option Data -> Edit Links and then select the file you want to change and press the "Change Source ..." button. Will update all the links (including on hidden sheets which you don't have to unhide) and in formulas. This menu option is also a good way to check if there are any left over missed links if you decided to use Fina and Replace.

The Find and Replace option is good if you only want to change come of the links.


2016-12-08 10:02:36

Konstantin Detchkov

My question is how to avoid Excel from changing the links when I "Save As."

Example:
I have a main file called "Rent Payment Log". It tracks only the payments made for different tenants. In that file I have "Payment Amount." This is linked to another file for "Arrears" where the "Payment Amount" is deducted from "Current Arrears". However, I need to save the "Rent Payment Log" for each month - "Rent Payment Log - January". Whenever I do that the links in in the "Arrears" file get changed to the new file "Rent Payment Log - January" instead of the main file, which is where I need them to stay permanently. How can I make sure that those links do not get changed when I am saving a file?


2016-09-19 23:35:32

ZZZ

I think the year should be 2015 not 2011 as they suggest when to perform Cntrl + H command. Mistype?


2015-11-13 16:28:59

Mike

Your final tip of :

=INDIRECT("['" & D5 & "']Sheet1!B3")

helped me out, but I had to tweak it to make it work.

I had to reverse the [ and the ' early on

=INDIRECT("'[" & D5 & "']Sheet1!B3")

the single quotation mark at the end of the bracketed section was moved between end of Sheet1 and the !

=INDIRECT("['" & D5 & "]Sheet1'!B3")

Thanks for the tips!


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.