ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   cell reference in another workbook (https://www.excelbanter.com/excel-programming/290309-cell-reference-another-workbook.html)

spence[_3_]

cell reference in another workbook
 
if i have workbook1 open can i reference a cell value in
a different workbook that is closed (workbook2).

so if i had:

Private Sub CommandButton1_Click()
workbook1.sheets("Sheet1").range("A1").value = _
workbook2.sheets("sheet1").range("Q98").value
End Sub
would something like this work?
i am not sure on the syntax of referencing a different
workbook.

i am actually tring to import a range of workbook2 into
workbook1. or more specifically copy a range from 1
into 2. TIA...S

Tom Ogilvy

cell reference in another workbook
 
Private Sub CommandButton1_Click()
With workbook1.sheets("Sheet1").range("A1")
.Formula = "=" & _
"'C:\Folder\[workbook2.xls]Sheet1'!Q98"
.Formula = .Value
End With
End Sub

Linking to a closed workbook is more easily done through Excel. VBA doesn't
support it.

--
Regards,
Tom Ogilvy


spence wrote in message
...
if i have workbook1 open can i reference a cell value in
a different workbook that is closed (workbook2).

so if i had:

Private Sub CommandButton1_Click()
workbook1.sheets("Sheet1").range("A1").value = _
workbook2.sheets("sheet1").range("Q98").value
End Sub
would something like this work?
i am not sure on the syntax of referencing a different
workbook.

i am actually tring to import a range of workbook2 into
workbook1. or more specifically copy a range from 1
into 2. TIA...S





All times are GMT +1. The time now is 12:24 PM.

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