Here is a simple example. I changed the path and name to match where I happen to have the file.
In a Standard Module:
Option Explicit
Sub example()
Dim wbSource As Workbook
Dim wksSource As Worksheet
Dim bolOpenedWB As Boolean
'// Allow, just for one line, bypassing error handling.//
On Error Resume Next
Set wbSource = Workbooks("Source (pwd is 1234).xlsx")
On Error GoTo 0
If wbSource Is Nothing Then '//If wbSource was not Set, it was not open, so open it and set a reference to it.//
Set wbSource = _
Workbooks.Open(Filename:="E:\vbax\vbax-50371-Excel-VBA-to-copy-cells-from-password-protected-file-into-another-file\Source (pwd is 1234).xlsx", _
UpdateLinks:=False, _
ReadOnly:=True, _
Password:="1234")
'// Set a flag, so we know to close it.//
bolOpenedWB = True
End If
'//SAA; in this case, if we do not find the correct sheet in the source wb, we can handle without any big errors//
On Error Resume Next
Set wksSource = wbSource.Worksheets("Sheet1")
On Error GoTo 0
'// If we found the sheet, grab values; else, advise//
If Not wksSource Is Nothing Then
'// NOTE: I used the default CodeName of the sheet, which I like better (presuming the sheet will not be deleted)//
Sheet1.Range("A1:B6").Value = wksSource.Range("H10:I15").Value
Else
MsgBox "YIKES!", vbOKOnly, vbNullString
End If
'// If we opened it, close it.//
If bolOpenedWB Then
wbSource.Close False
End If
End Sub
See the attached...
Hope that helps,
Mark