Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default workbooks.open

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default workbooks.open

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

In article ,
Jim Cottrell wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default workbooks.open

That worked perfectly!
Thanks so much!

"JE McGimpsey" wrote:

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

In article ,
Jim Cottrell wrote:

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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
when i open an Excell file 3 workbooks open.Why? Iain40 Excel Discussion (Misc queries) 2 February 3rd 09 05:04 PM
When I open Excel, workbooks open automatically. How can I stop t Rhealbird Excel Discussion (Misc queries) 2 February 23rd 06 10:08 AM
Excel 2003 Workbooks.Open with CorruptLoad=xlRepairFile fails on Excel 5.0/95 file due to Chart, with Error 1004 Method 'Open' of object 'Workbooks' failed Frank Jones Excel Programming 2 June 15th 04 03:21 AM
Workbooks.Open closes other workbooks S. Daum Excel Programming 1 August 21st 03 07:47 PM
Workbooks.Open / .Open Text - How do you stop the .xls addition? Dave[_20_] Excel Programming 2 July 31st 03 04:03 AM


All times are GMT +1. The time now is 07:41 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"