Select other workbook to select data in a macro.

T

T Tromp

Hi everyone,

If got a problem.
I want to select data in an other workbook to copy it to
the workbook the macro is placed on. I recorded the macro
and it workes well.
But the problem is that everytime the macro is started
Excel askes where the file(for retrieving data) is. So
everytime i have to browse and point out the file.

This is the VB code:

ActiveCell.FormulaR1C1 = _
"=[theDataFile.xls]ColumnName!R2C1:R2C3"

I tried many things...
like:

ActiveCell.FormulaR1C1 = _
"=[C:\2003\theDataFile.xls]ColumnName!R2C1:R2C3"

but nothing works...!!
please help...

Thomas Tromp
 
C

Cole

Sub test()
Workbooks.Open Filename:= _
"Path & Servant"
'---------
Workbooks("Master").Activate
'copy procedures
ActiveCell.FormulaR1C1 = _
"=[Servant]ColumnName!R2C1:R2C3"
'---------
Workbooks("Servant").Close
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top