![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Mar 2002
Posts: 75
|
Thanks to all who have helped me so far. I have 2 quick questions.
I have the current code as follows: Sub test() Dim Source As String Dim Path As String Dim sht As String Path = Worksheets("List").Cells(1, 1) For i = 0 To 500 Source = Worksheets("list").Cells(2 + i, 1) ChDir Path Workbooks.Open FileName:=Source Windows("Estimate Summary.xls").Activate Worksheets("ITEMS").Select Worksheets("ITEMS").Cells(6 + i, 1).Select strfile = Source ActiveCell.FormulaR1C1 = "='" & strfile & "'!R9C3" If Source = blank Then End Next End Sub And it works fine, what I can't figure out is how to get the a variable for every given worksheeet in the workbook soucre. As you can tell Souce just refereces a cell in the current worksheet that is a name of a workbook with souce information. Each souce workworrk has 30 worksheets in it. The above works great in getting to the first worksheet. Then it stops. Any sugestions out there? Also is there a way to go into workbooks and disassociate all the old links? I have kind of made a mess of some sheets experimenting with these macros linking them together. When I am done I don't want a bunch of bogus links lurking out there. Thanks in advance, this forum is a great resouce. |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
|
I haven't tested this code, but it should work:
Sub test() Dim Source As String Dim Path As String Dim NumSheets As Long Dim SheetName As String NumSheets = ThisWorkbook.Worksheets.Count For h = 1 To NumSheets SheetName = ThisWorkbook.Worksheets(h).Name Path = Worksheets(SheetName).Cells(1, 1) For i = 0 To 500 Source = Worksheets(SheetName).Cells(2 + i, 1) ChDir Path Workbooks.Open Filename:=Source Windows("Estimate Summary.xls").Activate Worksheets(SheetName).Select Worksheets(SheetName).Cells(6 + i, 1).Select strfile = Source ActiveCell.FormulaR1C1 = "='" & strfile & "'!R9C3" If Source = blank Then End Next Next h End Sub Hope this helps. Kind regards, Al. |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|