+ Reply to Thread
Results 1 to 9 of 9

VBA to combine the first sheet of numerous excel files into one master document

  1. #1
    Registered User
    Join Date
    11-26-2015
    Location
    Bradford, England
    MS-Off Ver
    Microsoft excel 2010
    Posts
    13

    VBA to combine the first sheet of numerous excel files into one master document

    Hi,

    I wonder if anyone could please help

    I have a number of excel files (approx ten, maybe a few more) which each contain a summary sheet on the first tab. (They all have different names but if need be I could rename them Sheet1)

    Each summary sheet has a graph, commentary, key stats etc and the idea is to easily combine all the summary pages into one combined report.

    I only want the first sheet of each document within the master document (the other data source tabs are not required)

    All files are stored in the same folder.

    My plan was to put them all in the same folder, create a new excel document containing vba to complete this function.

    As an vba novice however, this is proving far more difficult than first anticipated!

    If anyone could help in anyway it would be most appreciated!

    Many thanks in advance

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: VBA to combine the first sheet of numerous excel files into one master document

    Try something like this. Change the folder to suit.

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    11-26-2015
    Location
    Bradford, England
    MS-Off Ver
    Microsoft excel 2010
    Posts
    13

    Re: VBA to combine the first sheet of numerous excel files into one master document

    Thankyou so much for your quick answer! and thankyou for taking the time to help!

    I've changed the file path but it says 0 sheets copied. I'm not sure where I could be going wrong? Any ideas?

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: VBA to combine the first sheet of numerous excel files into one master document

    Show your changes. Perhaps you missed something.

  5. #5
    Registered User
    Join Date
    11-26-2015
    Location
    Bradford, England
    MS-Off Ver
    Microsoft excel 2010
    Posts
    13

    Re: VBA to combine the first sheet of numerous excel files into one master document

    Sub Consolidate_Summary_Sheets()

    Dim strPath As String, strFile As String, counter As Long

    strPath = "C:\Users\u25\Desktop\New folder\"
    strFile = Dir(strPath & "*.xls*")

    Application.ScreenUpdating = False
    Do While strFile <> ""
    With Workbooks.Open(strPath & strFile)
    .Sheets(1).Copy After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)
    ThisWorkbook.ActiveSheet.UsedRange.Value = ThisWorkbook.ActiveSheet.UsedRange.Value
    .Close SaveChanges:=False
    End With
    counter = counter + 1
    strFile = Dir
    Loop
    Application.ScreenUpdating = True

    MsgBox counter & " sheets copied. ", vbInformation, "Copy Summary Sheets Complete"

    End Sub

  6. #6
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: VBA to combine the first sheet of numerous excel files into one master document

    Looks good to me. Double-check your path and make sure the files are truly there. Otherwise, I don't know what to tell you.

    Take note of my signature block below about the use of CODE tags. It's a forum rule.

  7. #7
    Registered User
    Join Date
    11-26-2015
    Location
    Bradford, England
    MS-Off Ver
    Microsoft excel 2010
    Posts
    13

    Re: VBA to combine the first sheet of numerous excel files into one master document

    Thankyou for all your help and taking the time to help me.

    Unfortunately it still doesnt work.

    I have all files in one folder.
    The vba in a new excel document within this folder.
    Different names on the sheet first pages.
    The documents saved in Microsoft Excel Worksheet (.xlsx) format

    could any of these affect the result do you know?

  8. #8
    Registered User
    Join Date
    11-26-2015
    Location
    Bradford, England
    MS-Off Ver
    Microsoft excel 2010
    Posts
    13

    Re: VBA to combine the first sheet of numerous excel files into one master document

    I changed the name of the file format and it works! awesome! thankyou so much for your help!

  9. #9
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: VBA to combine the first sheet of numerous excel files into one master document

    You're welcome. Glad you figured it out.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 3
    Last Post: 02-13-2015, 10:09 PM
  2. [SOLVED] combine multi workbooks into one master workbook but I want to combine only sheet 3
    By Goodstart14 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-31-2013, 12:22 AM
  3. Problems linking numerous sheets in workbook to one master sheet
    By Joanne2013 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-15-2013, 05:50 AM
  4. [SOLVED] Code to copy numerous sheet cell ranges to a word document on my desktop
    By matrixpom in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-21-2013, 07:48 PM
  5. Replies: 5
    Last Post: 03-07-2012, 06:45 AM
  6. One Master File that will be cut rows and saved into numerous files
    By asian_xl in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-31-2009, 12:22 AM
  7. Linking Numerous Spreadsheets to one Master Sheet.......
    By Merlin54k in forum Excel General
    Replies: 5
    Last Post: 12-17-2007, 09:48 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1