Consulting

Results 1 to 3 of 3

Thread: Solved: Add opened file into a summary workbook

  1. #1
    VBAX Newbie
    Joined
    Aug 2009
    Posts
    1
    Location

    Solved: Add opened file into a summary workbook

    Hi!

    I am new to using VB in excel and I need some help. I am doing a program where in I need to open several files in a folder then add those opened sheets in a file, this file contains 1 sheet which will summarize all the data in the opened worksheets. I have a sample code but this code will create new file not add the opened files into a summary file.
    sample code:
    [VBA]
    Dim newWB As Workbook, aWB As Workbook
    Set newWB = Workbooks.Add
    For Each aWB In Application.Workbooks
    If aWB Is newWB Or aWB Is ThisWorkbook Then
    Else
    aWB.Sheet(1).Move after:=newWB.Sheet(1)
    End If
    Next aWB
    [/VBA]
    Hope you could help me. Thanks

    hi77l

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    You can easily get a master wb like so

    [vba]

    Dim masterWB As Workbook, aWB As Workbook
    Set masterWB = Workbooks("Master.xls")
    For Each aWB In Application.Workbooks
    [/vba]

    But ... this code is iterating through already opened workbooks. Do you want to open other workbooks in a nominated directory and process those?
    ____________________________________________
    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
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    hi77l, you posted this question at MrExcel here http://www.mrexcel.com/forum/showthread.php?t=410098 at 03:40 ish this morning, 5 hours is not a sufficient waiting time before crossposting!, if you must cross post please supply the link(s) to every other thread you created in every other forum - read the link about crossposting in my signature to see why it can be a problem
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

Posting Permissions

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