modification to this code

J

James

I had some help with this code some months ago, and I could use a help
modifying it again.

Option Explicit

Sub GetReportsDataOnly()
Dim i As Long
Dim varr As Variant
Dim wkbk As Workbook
Dim sh As Object
Dim mybook As Workbook
Dim myExistingPath As String
Dim myPathToRetrieve As String

myExistingPath = CurDir
myPathToRetrieve = "X:\2502521400"
ChDrive myPathToRetrieve
ChDir myPathToRetrieve

varr = Application.GetOpenFilename(filefilter:="Excel Files, *.xls", _
MultiSelect:=True)

If IsArray(varr) Then
For i = LBound(varr) To UBound(varr)
Set wkbk = Workbooks.Open(varr(i))
With wkbk.Worksheets("INZONE")
On Error Resume Next
Set mybook = Workbooks.Open(.FoundFiles(i))
mybook.Close SaveChanges:=False
.UsedRange.Value = .UsedRange.Value
.Copy after:=ThisWorkbook.Worksheets _
(ThisWorkbook.Worksheets.Count)
End With
wkbk.Close SaveChanges:=False
Next
End If

'reset it back
ChDrive myExistingPath
ChDir myExistingPath

End Sub

The code goes and grabs any worksheet called "INZONE" from the
"X:\2502521400" folder , I still would like it to do this but I need it to
start at a parent directory called "X:\" and work its way through all the
folders at this level and pull anything called "INZONE".

In the workbooks that it is going through I do have sheets called "INZONE 1,
INZONE 2..." I would like for it to grabs those as well.

Thanks for the help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top