Hi all,
I'm trying to combine sheet1's of different workbooks, and all insert into one large workbook. Please see my code below:
Sub GetSheets()
Path = "C:\Training\VBA\Practice\"
Filename = Dir(Path & "*.xls")
Do While Filename <> ""
Workbooks.Open Filename:=Path & Filename, ReadOnly:=True
For Each Sheet In ActiveWorkbook.Sheets
Sheet.Copy After:=ThisWorkbook.Sheets(1)
Next Sheet
Workbooks(Filename).Close
Filename = Dir()
Loop
End Sub
However, apparently what has happened was the macro inserted ALL worksheets from all workbooks and combined into one, which is not what I'm looking for. How do I only insert sheet1's and leave out the rest?
Evidently my experience with VBA is limited, so any input and help on this issue here is much appreciated. Also, if I were to insert the first sheet1 from different workbooks if their respective names were different (say Maximum, Minimum, Deductible, etc.), how would I do that? I guess that's the second question I have.
Thanks in advance again!
KDP
I'm trying to combine sheet1's of different workbooks, and all insert into one large workbook. Please see my code below:
Sub GetSheets()
Path = "C:\Training\VBA\Practice\"
Filename = Dir(Path & "*.xls")
Do While Filename <> ""
Workbooks.Open Filename:=Path & Filename, ReadOnly:=True
For Each Sheet In ActiveWorkbook.Sheets
Sheet.Copy After:=ThisWorkbook.Sheets(1)
Next Sheet
Workbooks(Filename).Close
Filename = Dir()
Loop
End Sub
However, apparently what has happened was the macro inserted ALL worksheets from all workbooks and combined into one, which is not what I'm looking for. How do I only insert sheet1's and leave out the rest?
Evidently my experience with VBA is limited, so any input and help on this issue here is much appreciated. Also, if I were to insert the first sheet1 from different workbooks if their respective names were different (say Maximum, Minimum, Deductible, etc.), how would I do that? I guess that's the second question I have.
Thanks in advance again!
KDP