Loading

Got a version of Excel that uses the
menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)?
**This site is for you!** If you
use a later version of Excel, visit
our *ExcelTips* site focusing on the ribbon interface.

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.

Learn more about Allen...

ExcelTips FAQ

ExcelTips Resources

Ask an Excel Question

Make a Comment

Free Business Forms

Free Calendars

** Please Note:** This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later),

When you use Excel's Paste tool to create a reference to a cell in another Excel workbook (not another worksheet in the same workbook), Excel creates the reference in this manner:

='[Sales Master.xls]Sheet1'!$A$5

The presence of the dollar signs means that this is an absolute reference to the cell. Because of this, you cannot use any of Excel's automatic fill options, such as Fill Right (**Ctrl+R**) or Fill Down (**Ctrl+D**) or AutoFill, and get the results you expect. Instead, every cell in the filled cells will reference the exact same cell in the external workbook.

The solution to the problem is to make a quick modification to the referencing formula before you do the fill. If you remove the dollar signs (both of them), then the formula is now relative, and filling will work the way you expect.

*ExcelTips* is your source for cost-effective Microsoft Excel training. This tip (2437) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Filling References to Another Workbook.

*Related Tips:*

**Save Time and Supercharge Excel!** Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out *Excel 2010 VBA and Macros* today!

Hi Ed,

I do not know if it is possible to use a formula which could be dragged across to give the results that you want.

A single line VBA code can be used as below ( I also give a more explicit Code version to aid in understanding the code )

The code will put a Formula in cell A1 and B1 like this:

= '[MyOtherOpenFile.xlsx]Sheet1'!$A$5 and ='[MyOtherOpenFile.xlsx]Sheet2'!$A$5

Alan

Sub FormulaAcrossWorksheetSHimpfGlified() ' Simplified

Range("A1:B1").Value = Evaluate("""='[MyOtherOpenFile.xlsx]Sheet""" & "&" & "Column(" & Range("A1:B1").Address & ")" & "&" & """'!$A$5""")

End Sub

Sub FormulaAcrossWorksheet() ' http://excel.tips.net/T002437_Filling_References_to_Another_Workbook.html Ed: 03 Jan 2017, 07:25

' Change Workbook and Worksheet names in formula and change Range to suit yours

' Final Formula string required is like ='[" & ActiveWorkbook.Name & "]Sheet1'!$A$5

' Formula strings as written manually in cell are like ='[concatanating.xlsm]Sheet1'!$A$5 ='[MyOtherOpenFile.xlsx]Sheet1'!$A$5

' Formula string for VBA string build is like "='[" & ActiveWorkbook.Name & "]Sheet1'!$A$5"

' Evalute(" ") to return a string will need an extra enclosing " in final String which requires a double "" in a VBA string.

' As Evaluate takes a string argument, we may build that string in VBA using text strings concatenated VBA Functions and Spreadsheet Functions

'Worksheets info

Dim Ws As Worksheet

Set Ws = ActiveSheet

Dim rngAB As Range ' Range object to be filed with all formulas

Set rngAB = Ws.Range("A1:B1")

'Put formula into first cell of Range Object

Let rngAB.Item(1, 1).Value = "='[" & ActiveWorkbook.Name & "]Sheet1'!$A$5"

' use Evaluate to put formulas into first cell of Range Object

Dim strEval As String: Let strEval = """='[" & ActiveWorkbook.Name & "]Sheet1'!$A$5"""

Let rngAB.Item(1, 1).Value = Evaluate(strEval)

' use Evaluate to fill in Worksheet Name dynamically

Let strEval = """='[" & ActiveWorkbook.Name & "]Sheet""" & "&" & """1""" & "&" & """'!$A$5"""

Let strEval = """='[" & ActiveWorkbook.Name & "]Sheet""" & "&" & 1 & "&" & """'!$A$5"""

Let strEval = """='[" & ActiveWorkbook.Name & "]Sheet""" & "&" & "Column(A1)" & "&" & """'!$A$5"""

Let strEval = """='[" & ActiveWorkbook.Name & "]Sheet""" & "&" & "Column(" & rngAB.Item(1, 1).Address & ")" & "&" & """'!$A$5"""

Let rngAB.Item(1, 1).Value = Evaluate(strEval)

' extending to more than one cell

Let strEval = """='[" & ActiveWorkbook.Name & "]Sheet""" & "&" & "Column(" & rngAB.Address & ")" & "&" & """'!$A$5"""

Let strEval = """='[MyOtherOpenFile.xlsx]Sheet""" & "&" & "Column(" & rngAB.Address & ")" & "&" & """'!$A$5"""

Dim arr() As Variant 'Evaluate involving Fuctions returning Arrays of values returns a field (Array) of Member Elements of variant Type

Let arr() = Evaluate(strEval)

Let rngAB.Value = arr() '.Value refers to (for a Range object of more than one contigous cells) an Array Property to which an Array ov values may be assigned directly

End Sub

' http://www.eileenslounge.com/viewtopic.php?f=27&t=25298

' Code _8) http://www.eileenslounge.com/viewtopic.php?f=27&t=25068

I do not know if it is possible to use a formula which could be dragged across to give the results that you want.

A single line VBA code can be used as below ( I also give a more explicit Code version to aid in understanding the code )

The code will put a Formula in cell A1 and B1 like this:

= '[MyOtherOpenFile.xlsx]Sheet1'!$A$5 and ='[MyOtherOpenFile.xlsx]Sheet2'!$A$5

Alan

Sub FormulaAcrossWorksheetSHimpfGlified() ' Simplified

Range("A1:B1").Value = Evaluate("""='[MyOtherOpenFile.xlsx]Sheet""" & "&" & "Column(" & Range("A1:B1").Address & ")" & "&" & """'!$A$5""")

End Sub

Sub FormulaAcrossWorksheet() ' http://excel.tips.net/T002437_Filling_References_to_Another_Workbook.html Ed: 03 Jan 2017, 07:25

' Change Workbook and Worksheet names in formula and change Range to suit yours

' Final Formula string required is like ='[" & ActiveWorkbook.Name & "]Sheet1'!$A$5

' Formula strings as written manually in cell are like ='[concatanating.xlsm]Sheet1'!$A$5 ='[MyOtherOpenFile.xlsx]Sheet1'!$A$5

' Formula string for VBA string build is like "='[" & ActiveWorkbook.Name & "]Sheet1'!$A$5"

' Evalute(" ") to return a string will need an extra enclosing " in final String which requires a double "" in a VBA string.

' As Evaluate takes a string argument, we may build that string in VBA using text strings concatenated VBA Functions and Spreadsheet Functions

'Worksheets info

Dim Ws As Worksheet

Set Ws = ActiveSheet

Dim rngAB As Range ' Range object to be filed with all formulas

Set rngAB = Ws.Range("A1:B1")

'Put formula into first cell of Range Object

Let rngAB.Item(1, 1).Value = "='[" & ActiveWorkbook.Name & "]Sheet1'!$A$5"

' use Evaluate to put formulas into first cell of Range Object

Dim strEval As String: Let strEval = """='[" & ActiveWorkbook.Name & "]Sheet1'!$A$5"""

Let rngAB.Item(1, 1).Value = Evaluate(strEval)

' use Evaluate to fill in Worksheet Name dynamically

Let strEval = """='[" & ActiveWorkbook.Name & "]Sheet""" & "&" & """1""" & "&" & """'!$A$5"""

Let strEval = """='[" & ActiveWorkbook.Name & "]Sheet""" & "&" & 1 & "&" & """'!$A$5"""

Let strEval = """='[" & ActiveWorkbook.Name & "]Sheet""" & "&" & "Column(A1)" & "&" & """'!$A$5"""

Let strEval = """='[" & ActiveWorkbook.Name & "]Sheet""" & "&" & "Column(" & rngAB.Item(1, 1).Address & ")" & "&" & """'!$A$5"""

Let rngAB.Item(1, 1).Value = Evaluate(strEval)

' extending to more than one cell

Let strEval = """='[" & ActiveWorkbook.Name & "]Sheet""" & "&" & "Column(" & rngAB.Address & ")" & "&" & """'!$A$5"""

Let strEval = """='[MyOtherOpenFile.xlsx]Sheet""" & "&" & "Column(" & rngAB.Address & ")" & "&" & """'!$A$5"""

Dim arr() As Variant 'Evaluate involving Fuctions returning Arrays of values returns a field (Array) of Member Elements of variant Type

Let arr() = Evaluate(strEval)

Let rngAB.Value = arr() '.Value refers to (for a Range object of more than one contigous cells) an Array Property to which an Array ov values may be assigned directly

End Sub

' http://www.eileenslounge.com/viewtopic.php?f=27&t=25298

' Code _8) http://www.eileenslounge.com/viewtopic.php?f=27&t=25068

Is there some way I can get it to increment the sheet numbers - so that an adjacent cell would have an external reference to cell A5 on Sheet2 ?

Woah! thanks for this, i've been loking for this solution since 3 days and cannot find any same like this online. you make my job a lot more easier. Cool!