workbooks.open

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to open 4 files with a macro. If I just open one file it works.
If I try to open more than one, I get a subscript out of range error.
Can you help me with this?
Thanks!

Workbooks.Open Sheets("files").Range("C3").Value
Workbooks.Open Sheets("files").Range("C4").Value
 
After the first workbooks.open, the opened workbook is the active
workbook, so your reference to Sheets("files").Range(..) is invalid
unless the just opened workbook has a worksheet named "files".

Try:

With ThisWorkbook.Sheets("files")
Workbooks.Open .Range("C3").Value
Workbooks.Open .Range("C4").Value
End With
 
That worked perfectly!
Thanks so much!

JE McGimpsey said:
After the first workbooks.open, the opened workbook is the active
workbook, so your reference to Sheets("files").Range(..) is invalid
unless the just opened workbook has a worksheet named "files".

Try:

With ThisWorkbook.Sheets("files")
Workbooks.Open .Range("C3").Value
Workbooks.Open .Range("C4").Value
End With
 

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

Back
Top