My code-can't get it work right

kluitna

Board Regular
Joined
Mar 10, 2002
Messages
75
here is my code:

Sub test()
Dim Source As String
Dim Path As String
Dim NumSheets As Long
Dim SheetName As String
Path = Worksheets("List").Cells(1, 1)
For i = 0 To 500
Source = Worksheets("list").Cells(2 + i, 1)
If Source = blank Then End
ChDir Path
Workbooks.Open FileName:=Source
For h = 1 To 30
Windows("Estimate Summary.xls").Activate
Worksheets("ITEMS").Select
Worksheets("ITEMS").Cells(6 + i, 1 + h).Select
strfile = Source
SheetName = Workbooks(Source).Worksheets(h).Name
ActiveCell.FormulaR1C1 = "='" & [strfile] & "'!R21C4"
Workbooks.Open (Source)
ActiveSheet.Cells(21, 4).Select
Selection.Copy
Windows("Estimate Summary.xls").Activate
Worksheets("ITEMS").Cells(6 + i, 1 + h).Select
Selection.PasteSpecial Paste:=xlFormats, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Next h
Next
End Sub

Its works sort of.. 2 problems,

1) the formula that looks back at the souce file to link to the estimate summary I can not make it roll through the diffeent sheets in a given source file. does anyone out there know the code to do this?

2) i have been trying to figure out how to close the source file before. opening a new one and rolling though the sheets in the new file.

my fore head is bloody for some constant head banging.. in need of a medic!!!
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Forum statistics

Threads
1,214,584
Messages
6,120,384
Members
448,956
Latest member
JPav

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top