I am producing a sheet to calculate prices. The sheet has to have a reference to several other workbooks to get the prices for different components. This works fine on my computer but when I move them to the server or another computer, it can't find the references.
My folder is structured like:
Folder
|-- prices.xlsx
|-- Fixed Components
| |-- ComponentsA.xlsx
| +-- ComponentsB.xlsx
|
+-- Variable Components
|-- ComponentsC.xlsx
+-- ComponentsD.xlsx
prices.xlsx
is the main sheet that references the other sheets. On my computer it builds the references with an absolute path, so when I copy the files the path stays fixed to my machine, instead of referencing the the files on the other PC.
Is there any way to make the references relative so that I can put in the main sheet something like ='\Variable Components\[ComponentsC.xlsx]Sheet1'!A1
. I would not want to use VBA for this as people don't tend to trust Macros and then complain the functions don't work.
To reference a cell or range of cells in another worksheet in the same workbook, put the worksheet name followed by an exclamation mark (!) before the cell address. For example, to refer to cell A1 in Sheet2, you type Sheet2! A1.
Create a cell reference to another worksheet Click the cell in which you want to enter the formula. , type = (equal sign) and the formula you want to use. Click the tab for the worksheet to be referenced. Select the cell or range of cells to be referenced.
Click the tab for the first worksheet that you want to reference. Hold down the Shift key then click the tab for the last worksheet that you want to reference. Select the cell or range of cells that you want to reference. Complete the formula, and then press Enter.
The only solutions that I've seen to organize the external files into sub-folders has required the use of VBA to resolve a full path to the external file in the formulas. Here is a link to a site with several examples others have used:
http://www.teachexcel.com/excel-help/excel-how-to.php?i=415651
Alternatively, if you can place all of the files in the same folder instead of dividing them into sub-folders, then Excel will resolve the external references without requiring the use of VBA even if you move the files to a network location. Your formulas then become simply ='[ComponentsC.xlsx]Sheet1'!A1
with no folder names to traverse.
I had a similar problem that I solved by using the following sequence:
use the CELL("filename")
function to get the full path to the current sheet of the current file.
use the SEARCH()
function to find the start of the [FileName]SheetName string of your current excel file and the sheet.
use the LEFT
function to extract the full path name of the directory that contains your current file.
Concatenate the directory path name found in step #3 with the name of the file, the name of the worksheet, and the cell reference that you want to access.
use the INDIRECT()
function to access the CellPathName
that you created in step #4.
Note: these same steps can also be used to access cells in files whose names are created dynamically. In step #4, use a text string that is dynamically created from the contents of cells, the current date or time, etc. etc.
A cell reference example (with each piece assembled separately) that includes all of these steps is:
=INDIRECT("'" & LEFT(CELL("filename"),SEARCH("[MyFileName]MySheetName",CELL("filename")) - 1) & "[" & "OtherFileName" & "]" & "OtherSheetName" & "'!" & "$OtherColumn$OtherRow" & "'")
Note that LibreOffice uses a slightly different CellPatnName syntax, as in the following example:
=INDIRECT(LEFT(CELL("filename"),SEARCH("[MyFileName]MySheetName",CELL("filename")) - 1) & "OtherFileName" & "'#$" & "OtherSheetName" & "." & "$OtherColumn$OtherRow")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With