+ Reply to Thread
Results 1 to 7 of 7

Code for pulling data from multiple files into one master worksheet

  1. #1
    Registered User
    Join Date
    02-17-2015
    Location
    England
    MS-Off Ver
    2010
    Posts
    32

    Code for pulling data from multiple files into one master worksheet

    Hi all,

    Sorry for posting this as I know it has been asked before, however I don't know the right terminology to be able to complete the search and get what I am looking for, so hope you can help and point me in the right direction.

    I don't really know much about forms in excel so normally create a worksheet that looks like a word document with blank cells for text etc. to be entered. This then links to a hidden worksheet that pulls the data from the cells into a row. This row can then be copied and pasted into a master spreadsheet. I appreciate this may not be the best way to do it, however its the only way I know and works.

    However, this time I want to send out the spreadsheet to multiple people (100s) and request them to complete with their data and return. this means I will have 100s of files containing rows and don't want to have to manually copy and paste each line into the master worksheet. I have seen something where you put all the files into a folder and then run VBA/macro and it populates each row of data onto a new line in the master table.

    My questions are;
    What is the code?
    Will this work with a hidden worksheet?
    Will this work with a protected worksheet? (the hidden row is also locked to prevent editing)

    Would also be interested if there is a better way to create a form in excel that puts the data into a separate worksheet, but would still have the same issue that i would receive 100s of files so would then need to run the same vba/macro to put all the data into a master worksheet.

    Thanks in advance for your help,

  2. #2
    Valued Forum Contributor
    Join Date
    11-04-2018
    Location
    Denpasar
    MS-Off Ver
    Excel 2010
    Posts
    777

    Re: Code for pulling data from multiple files into one master worksheet

    I'm sorry as I cannot help you for the code, but a suggestion....

    Quote Originally Posted by MP1989 View Post
    However, this time I want to send out the spreadsheet to multiple people (100s)
    and request them to complete with their data and return.
    If you have Google Account, maybe you can try Google Spreadsheet.
    Let those hundreds people to access your spreadsheet and ask them to fill their data.

    If you can do that, then

    this means I will have 100s of files containing rows
    and don't want to have to manually copy and paste each line into the master worksheet.
    you will not have
    hundred files and you don't have to copy each of them manually.

  3. #3
    Registered User
    Join Date
    11-14-2018
    Location
    Saudi Arabia
    MS-Off Ver
    Office 2016, Office 2010
    Posts
    26

    Re: Code for pulling data from multiple files into one master worksheet

    In order to merge many files/sheet into one, there should be unique header or number in all 100 files.

  4. #4
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,700

    Re: Code for pulling data from multiple files into one master worksheet

    Re: In order to merge many files/sheet into one, there should be unique header or number in all 100 files.
    Why?
    One can copy/paste any column or row you want.
    If data under a specific header and these headers are not all under the same column number is to be copied only then you might have a valid argument.

  5. #5
    Registered User
    Join Date
    02-17-2015
    Location
    England
    MS-Off Ver
    2010
    Posts
    32

    Re: Code for pulling data from multiple files into one master worksheet

    My worksheet that will be completed will contain a hidden worksheet (called data) and contain 2 rows of data (1 contains headers and 1 contains the data).

    I want to put the files, when received into a folder and then be able to execute the VBA in the master workbook to pull the data from row 2 into the next blank line in a master spread sheet. I want to be able to keep adding new files received to the master and will move the files from the folder so that they aren't duplicated.

    I found a similar function that works for word documents into excel but thought this may be a lot simpler, however I am struggling to find a solution.

    Would be grateful for anyone's help

  6. #6
    Registered User
    Join Date
    11-14-2018
    Location
    Saudi Arabia
    MS-Off Ver
    Office 2016, Office 2010
    Posts
    26
    Quote Originally Posted by jolivanes View Post
    Re: In order to merge many files/sheet into one, there should be unique header or number in all 100 files.
    Why?
    One can copy/paste any column or row you want.
    If data under a specific header and these headers are not all under the same column number is to be copied only then you might have a valid argument.
    I mean, if you want to merge the data through vba, there should be unique header or code.

  7. #7
    Registered User
    Join Date
    02-17-2015
    Location
    England
    MS-Off Ver
    2010
    Posts
    32

    Re: Code for pulling data from multiple files into one master worksheet

    I managed to find a solution on google

    Sub GetFormData()
    'Note: this code requires a reference to the Word object model
    Application.ScreenUpdating = False
    Dim wdApp As New Word.Application, wdDoc As Word.Document, CCtrl As Word.ContentControl
    Dim strFolder As String, strFile As String, WkSht As Worksheet, i As Long, j As Long
    strFolder = "FOLDER NAME HERE"
    If strFolder = "" Then Exit Sub
    Set WkSht = ActiveSheet
    i = WkSht.Cells(WkSht.Rows.Count, 1).End(xlUp).Row
    strFile = Dir(strFolder & "\*.docx", vbNormal)
    While strFile <> ""
    i = i + 1
    Set wdDoc = wdApp.Documents.Open(Filename:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False)
    With wdDoc
    j = 0
    For Each CCtrl In .ContentControls
    With CCtrl
    Select Case .Type
    Case Is = wdContentControlCheckBox
    j = j + 1
    WkSht.Cells(i, j).Value = .Checked
    Case wdContentControlDate, wdContentControlDropdownList, wdContentControlRichText, wdContentControlText
    j = j + 1
    WkSht.Cells(i, j).Value = .Range.Text
    Case Else
    End Select
    End With
    Next
    .Close SaveChanges:=False
    End With
    strFile = Dir()
    Wend
    wdApp.Quit
    Set wdDoc = Nothing: Set wdApp = Nothing: Set WkSht = Nothing
    Application.ScreenUpdating = True
    End Sub

+ 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. [SOLVED] Pulling data from 3 different files into a master file
    By AnirudhC in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-30-2017, 08:26 PM
  2. Replies: 8
    Last Post: 03-14-2017, 03:49 PM
  3. Help pulling data from worksheets into a master worksheet
    By slalfor1 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-07-2016, 05:55 PM
  4. Merging multiple excel files in a folder into one master worksheet in a new worksheet
    By johnny_canuck in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 08-22-2013, 12:20 PM
  5. [SOLVED] Pulling Data from multiple Sheets into master worksheet
    By sdgg91 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-20-2013, 10:08 AM
  6. pulling data from a master worksheet
    By MountainGoat in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-06-2008, 11:02 AM
  7. Pulling data from individual files to master list
    By joshwimmer@gmail.com in forum Excel General
    Replies: 1
    Last Post: 05-22-2006, 05:40 PM

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