ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Use Cell as Source file (https://www.excelbanter.com/excel-programming/369833-use-cell-source-file.html)

ccl28[_5_]

Use Cell as Source file
 

Hi,

I would like to use the name in the C4 in Sheet1 as my source file as
xls file.
I have written a macro but have error. Attached please find the macro.

Anyone can help.

Thanks.


Sub Macro1()

Range("K10").Select
ActiveCell.FormulaR1C1 = "=[Sheet1!C4.xls]LeakFreq!R39C4"

End Sub


--
ccl28
------------------------------------------------------------------------
ccl28's Profile: http://www.excelforum.com/member.php...o&userid=36095
View this thread: http://www.excelforum.com/showthread...hreadid=569812


kassie

Use Cell as Source file
 
Your code does not help a lot, but
If you want to use a value in a cell to refer to a workbook name, you should
read this value into a varable. Something like wOne = Range("C4").value.
You can then refer to the workbook using wOne. You also cannot mix R1C1 and
A1 references, as you are doing.
ActiveCell.Formula = "='[" & wOne "]LeakFreq'!D39"
would give you the workbook referred to in C4

"ccl28" wrote:


Hi,

I would like to use the name in the C4 in Sheet1 as my source file as
xls file.
I have written a macro but have error. Attached please find the macro.

Anyone can help.

Thanks.


Sub Macro1()

Range("K10").Select
ActiveCell.FormulaR1C1 = "=[Sheet1!C4.xls]LeakFreq!R39C4"

End Sub


--
ccl28
------------------------------------------------------------------------
ccl28's Profile: http://www.excelforum.com/member.php...o&userid=36095
View this thread: http://www.excelforum.com/showthread...hreadid=569812




All times are GMT +1. The time now is 05:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com