cell reference in another workbook

S

spence

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
 
T

Tom Ogilvy

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.
 

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