Excel.Tips.Net Welcome toExcel.Tips.Net

Helpful Links

Tips.Net Home
ExcelTips Home
Ask an Excel Question
Make a Comment

Tips.Net Store

ExcelTips FAQ
ExcelTips Premium

Learn Access Now
Free Printable Forms

Beauty Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Legal Tips
Money Tips
Organizing Tips
Pest Tips
Pet Tips
Wedding Tips
Word2007 Tips
WordTips

Advertise on the
ExcelTips Site

Newest Tips

Converting to Octal

Filtering Columns for Unique Values

Printing Multiple Worksheets on a Single Page

Changing the Default Font

Creating a Drawing Object

Determining a Value of a Cell

Understanding Macros

 

Updating Links in Copied Files

Summary: When you copy workbooks that contain links, you may be at a loss as to how to update those links. There are a couple of ways you can approach the task, as discussed in this tip. (This tip works with Microsoft Excel 97, Excel 2000, Excel 2002, Excel 2003, and Excel 2007.)

Let's say you have two workbooks that you use for tracking sales in the current month, 2008JuneA.xls and 2008JuneB.xls, and that 2008JuneA.xls contains links to data in 2008JuneB.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 2008JuneA.xls and 2008JuneB.xls in Excel.
  2. Use Save As to save the 2008JuneB.xls file under the name 2008JulyB.xls.
  3. Use Save As to save the 2008JuneA.xls file under the name 2008JulyA.xls.

As part of saving out 2008JulyB.xls (step 2), Excel automatically updates all the links in 2008JuneA.xls so that they point to the new file name. When you then save 2008JulyA.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 2008JulyA.xls file.
  2. Press Ctrl+H to display the Replace tab of the Find and Replace dialog box. (Click here to see a related figure.)
  3. In the Find What box, enter the root portion of the old worksheet name (2008JuneB).
  4. In the Replace With box, enter the root portion of the new worksheet name (2008JulyB).
  5. 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 February folder, and then make a copy of the whole folder and name it March. 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:

=[2008JuneB.xls]Sheet1!B3

You could put the name of the source file (2008JuneB.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 (3447) applies to Microsoft Excel versions: 97 | 2000 | 2002 | 2003 | 2007

Save Time! ExcelTips has been published weekly since late 1998. Past issues of ExcelTips are available in convenient ExcelTips archives. Have your own enhanced archive of ExcelTips at your fingertips, available to use at any time!
 
Check out ExcelTips Archives today!