Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Opening a workbook based on a cell value

Not sure if this is possible but here goes:

I need to be able to look through a column of cells and
open each workbook whose name corresponds to the value in
each cell one at a time. Example:

Column H
931C
941
921B
900B

In this example it would look at column H, open 931C.xls,
do some "stuff" (including closing the workbook after it's
done),open 941.XLS, do its "stuff", open 921B.xls....

The "stuff" I can handle, just have no clue how to loop
through the column and open the files like I described.
Any help would be GREATLY appreciated.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Opening a workbook based on a cell value

Todd,

Try something like

Dim Rng As Range
Dim WB As Workbook
For Each Rng In Range("H1:H100") ' << change range as needed
If Rng.Value < "" Then
Set WB = Workbooks.Open(ThisWorkbook.Path & "\" &
Rng.Value & ".xls")
' do something with WB
WB.Close SaveChanges:=True
End If
Next Rng


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Todd" wrote in message
...
Not sure if this is possible but here goes:

I need to be able to look through a column of cells and
open each workbook whose name corresponds to the value in
each cell one at a time. Example:

Column H
931C
941
921B
900B

In this example it would look at column H, open 931C.xls,
do some "stuff" (including closing the workbook after it's
done),open 941.XLS, do its "stuff", open 921B.xls....

The "stuff" I can handle, just have no clue how to loop
through the column and open the files like I described.
Any help would be GREATLY appreciated.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Opening a workbook based on a cell value

Perfect...Thanks a million Chip
-----Original Message-----
Todd,

Try something like

Dim Rng As Range
Dim WB As Workbook
For Each Rng In Range("H1:H100") ' << change range as

needed
If Rng.Value < "" Then
Set WB = Workbooks.Open(ThisWorkbook.Path & "\" &
Rng.Value & ".xls")
' do something with WB
WB.Close SaveChanges:=True
End If
Next Rng


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Todd" wrote in

message
...
Not sure if this is possible but here goes:

I need to be able to look through a column of cells and
open each workbook whose name corresponds to the value

in
each cell one at a time. Example:

Column H
931C
941
921B
900B

In this example it would look at column H, open

931C.xls,
do some "stuff" (including closing the workbook after

it's
done),open 941.XLS, do its "stuff", open 921B.xls....

The "stuff" I can handle, just have no clue how to loop
through the column and open the files like I described.
Any help would be GREATLY appreciated.




.

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
Finding a Workbook based on a Cell information in another Workbook Walter Excel Worksheet Functions 1 October 10th 09 08:46 AM
opening a link in a workbook cell to edit?? MikeR-Oz New Users to Excel 1 September 21st 08 04:15 AM
On opening a worksheet move focus to a cell based on date davcas Excel Worksheet Functions 1 July 1st 08 02:18 PM
Active Cell when opening workbook mwclark0807 Excel Worksheet Functions 3 January 5th 06 04:38 AM
How to make opening of workbook conditional of opening of another workbook turk5555[_2_] Excel Programming 2 December 15th 03 11:07 PM


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

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

About Us

"It's about Microsoft Excel"