Consulting

Results 1 to 5 of 5

Thread: Pull data to new workbook with new sheet per workbook

  1. #1
    VBAX Newbie
    Joined
    Jun 2010
    Posts
    1
    Location

    Pull data to new workbook with new sheet per workbook

    I have multiple workbooks (all the same with different data) and wish to have a workbook that will pull certain data from them and create a new sheet in this new workbook for each one of the multiple workbooks with the respective data. HELP!!!!!!!!!!!!! I have no clue where to start

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Dim oFSO As Object

    Sub LoopFolders()
    Set oFSO = CreateObject("Scripting.FileSystemObject")

    selectFiles "c:\MyTest"

    Set oFSO = Nothing
    End Sub

    '---------------------------------------------------------------------------
    Sub selectFiles(sPath)
    '---------------------------------------------------------------------------
    Dim Folder As Object
    Dim Files As Object
    Dim file As Object
    Dim fldr

    Set Folder = oFSO.GetFolder(sPath)

    For Each fldr In Folder.Subfolders
    selectFiles fldr.Path
    Next fldr

    With ThisWorkbook

    For Each file In Folder.Files

    If file.Type Like "Microsoft*Excel*Worksheet*" Then

    Workbooks.Open Filename:=file.Path
    ActiveWorkbook.Worksheets("Sheet1").Copy After:=.Worksheets(.Worksheets.Count)
    ActiveWorkbook.Close savechanges:=False
    End If
    End If
    Next file
    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Hi Bob,

    Why the Like? A 2007 thing?

    Mark

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Not only 2007, it is also an OS thing as to how they identify workbooks.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Ahh, I did not think of Mac - thank you :-)

    If we do not 'chat', a great weekend to you and yours,

    Mark

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •