Coping Range from another Excel file

  • Thread starter Thread starter rameshs319
  • Start date Start date
R

rameshs319

Hi...

I am developing a application in Excel 2003 with userforms, that
requires a Range to be copied from external other excel file to a
specified sheet on the coding file. i tried using Inputbox(type 8) and
also ref edit function. Both links only sheets of the file and they
never point to the external file.
Any suggestions...?

Thanks
S.Ramesh
 
By external file, I assume you mean a different workbook. To access data in
a different workbook than the one your code is running in, you must specify
that workbook in the calling code.

ActiveWorkbook.Sheets(1).Range("A1") = _
Workbooks("myWB2").Sheets(1).Range("B1")

So when you try to use a variable to capture the data from another workbook,
the variable must contain the workbook reference also.

Set myVar = Workbooks("myWB2").Sheets(1)
ActiveWorkbook.Sheets(1).Cells(1, 1) = myVar.Range("B1")
 
Back
Top