• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Open file and reference a named range in an external workbook

JCTalk

Member
Hi guys,

Currently I'm referencing an external named range in a formula for cell A2 and copying it down until the last row (shown below).

Code:
With Worksheets("Sheet1")
lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
.Range("$A2").Formula = "=IF(SUMPRODUCT(--ISNUMBER(SEARCH('C:\Path\Filename.xlsm'!NamedRange,R2)))>0,TRUE,"""")"
.Range("$A2").AutoFill Destination:=Range("$A2:$A" & lastrow)
End With

I have to manually open the workbook first to make sure it doesn't crash on me, and also some of the forumula's end up so long it won't accept it.

What would be the best VBA way of opening a connection to the workbook (read only) in the background and referencing a named range in that external workbook in formula's, then closing the connection?

Many thanks
 
Back
Top