You don't need to select/activate the workbooks. Is the code in the
activeworkbook & you want to copy B2 from workbook1.xls?
Code:
--------------------
Option Explicit
Function IsOpen(wbName As String) As Boolean
Dim Wb As Workbook
On Error Resume Next
Set Wb = Workbooks(wbName)
If Err = 0 Then IsOpen = True
End Function
Sub copyRange()
Dim sFilName As String
sFilName = "WorkBook1.xls"
If Not IsOpen(sFilName) Then Workbooks.Open _
("C:" & sFilName & ".xls")
Workbooks(sFilName).Sheet1.Cells(2, 2).Copy _
ThisWorkbook.Sheet1.Cells(2, 2)
End Sub
--------------------
--
royUK
Hope that helps, RoyUK
For tips & examples visit my 'web site
' (
http://www.excel-it.com)
------------------------------------------------------------------------
royUK's Profile:
http://www.thecodecage.com/forumz/member.php?userid=15
View this thread:
http://www.thecodecage.com/forumz/sh...ad.php?t=28001