C
chunkylover57
How do I get this code to import all the new sheets into the current
active worksheet...Right now this opens a new book...I want this to
work in the active book..
Sub GetSheets()
Dim sPath As String, i As Long
Dim varr As Variant
Dim wkbk As Workbook
Dim wkbk1 As Workbook
Set wkbk1 = ActiveWorkbook
sPath = "C:\$user\PCO\"
varr = Array("itsr.xls", "tsr.xls", "tsm.xls", "tm.xls")
For i = LBound(varr) To UBound(varr)
Set wkbk = Workbooks.Open(sPath & varr(i))
If i = LBound(varr) Then
wkbk.Worksheets.Copy
Set wkbk1 = ActiveWorkbook
Else
wkbk.Worksheets.Copy After:=wkbk1. _
Worksheets(wkbk1.Worksheets.Count)
End If
wkbk.Close SaveChanges:=False
Next
End Sub
active worksheet...Right now this opens a new book...I want this to
work in the active book..
Sub GetSheets()
Dim sPath As String, i As Long
Dim varr As Variant
Dim wkbk As Workbook
Dim wkbk1 As Workbook
Set wkbk1 = ActiveWorkbook
sPath = "C:\$user\PCO\"
varr = Array("itsr.xls", "tsr.xls", "tsm.xls", "tm.xls")
For i = LBound(varr) To UBound(varr)
Set wkbk = Workbooks.Open(sPath & varr(i))
If i = LBound(varr) Then
wkbk.Worksheets.Copy
Set wkbk1 = ActiveWorkbook
Else
wkbk.Worksheets.Copy After:=wkbk1. _
Worksheets(wkbk1.Worksheets.Count)
End If
wkbk.Close SaveChanges:=False
Next
End Sub