ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Opening a list of workbooks (https://www.excelbanter.com/excel-programming/338439-opening-list-workbooks.html)

Barb Reinhardt

Opening a list of workbooks
 
I have a list of workbooks in a worksheet that I'd like to open
automatically. How would I do that using VB?

Thanks,
Barb Reinhardt



Tom Ogilvy

Opening a list of workbooks
 
Dim bk() as Workbook
redim bk(0 to selection.count - 1)
i = 0
for each cell in selection
set bk(i) = Workbooks.Open(cell.Value)
Next


This assumes the cells contain the fully qualified path as well if it is
required to find the workbook.

--
Regards,
Tom Ogilvy


"Barb Reinhardt" wrote in message
...
I have a list of workbooks in a worksheet that I'd like to open
automatically. How would I do that using VB?

Thanks,
Barb Reinhardt





Barb Reinhardt

Opening a list of workbooks
 
What if I define the name DEFECT for the series, what would need to be
changed?

"Tom Ogilvy" wrote in message
...
Dim bk() as Workbook
redim bk(0 to selection.count - 1)
i = 0
for each cell in selection
set bk(i) = Workbooks.Open(cell.Value)
Next


This assumes the cells contain the fully qualified path as well if it is
required to find the workbook.

--
Regards,
Tom Ogilvy


"Barb Reinhardt" wrote in message
...
I have a list of workbooks in a worksheet that I'd like to open
automatically. How would I do that using VB?

Thanks,
Barb Reinhardt







Tom Ogilvy

Opening a list of workbooks
 
Dim rng as Range
Dim bk() as Workbook
set rng = Range("Defect")
redim bk(0 to rng.count - 1)
i = 0
for each cell in rng
set bk(i) = Workbooks.Open(cell.Value)

Next



at some point
for i = lbound(bk) to ubound(bk)
bk(i).close SaveChanges:=False
Next


--
Regards,
Tom Ogilvy


"Barb Reinhardt" wrote in message
...
What if I define the name DEFECT for the series, what would need to be
changed?

"Tom Ogilvy" wrote in message
...
Dim bk() as Workbook
redim bk(0 to selection.count - 1)
i = 0
for each cell in selection
set bk(i) = Workbooks.Open(cell.Value)
Next


This assumes the cells contain the fully qualified path as well if it is
required to find the workbook.

--
Regards,
Tom Ogilvy


"Barb Reinhardt" wrote in message
...
I have a list of workbooks in a worksheet that I'd like to open
automatically. How would I do that using VB?

Thanks,
Barb Reinhardt










All times are GMT +1. The time now is 10:53 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com