+ Reply to Thread
Results 1 to 13 of 13

Extract and transpose specific cell data from multiple files

  1. #1
    Registered User
    Join Date
    07-31-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    34

    Extract and transpose specific cell data from multiple files

    Hi all,

    I currently have over 2,000 excel files (and growing) in a folder that are identical in format.

    I am looking to extract the specific data from these files in Sheet1 cells B15, B19, B22, B23, B24, B25 and paste it as values only in a new Workbook, however, transposed into Rows beginning at A2.
    So:
    B15 = A2
    B19 = B2
    B22 = C2
    B23 = D2…etc

    As the folder grows it would be great if I could simply click a button to update the file as and when required.

    Any assistance would be greatly appreciated.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Extract and transpose specific cell data from multiple files

    What do you mean by "update"? Normally running the macro would open all 2000 files again and reimport again.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    07-31-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: Extract and transpose specific cell data from multiple files

    Hi there,

    On a daily basis the folder will be added to. At the end of the week I guess I would look to run the macro again to extract all the data into a fresh spreadsheet thus reimport.

    Hope that helps?

    Kind regards,

    Mad-Dog

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Extract and transpose specific cell data from multiple files

    So, a clean reimport each time it occurs... so the macro simply does the same thing in full each time?

    I ask because the macro could also record the full path/name of the file the data was taken from, say we record that in column Z. Then when the macro is run a second time, it can see the files that have already been in imported and skip them, only opening new files and adding them to the bottom of the existing collected data.

    Sound ok?

  5. #5
    Registered User
    Join Date
    07-31-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: Extract and transpose specific cell data from multiple files

    LOL....mate as a true numpty I am in your capable hands and will appreciate anything you can do to make my life easier.

    It all sounds good and I am loking forward to giving the code a test drive.

    Many thanks.

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Extract and transpose specific cell data from multiple files

    This is a common method, base macro is published here.

    I've edited that macro for your scenario, you'll need to edit the fPath = ..... line of code to point to the folder where the incoming files are stored. (marked in red below).

    The macro will open each file in that path, check to see if a line already exists in the consolidation master sheet by checking the filenames recorded in column Z. IF it exists, it will update that existing row, else it will append the new data/sheet to the bottom of the list.

    Each imported file is then moved into an "imported" folder. Lather, rinse, repeat.

    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 12-27-2019 at 04:07 AM.

  7. #7
    Registered User
    Join Date
    07-31-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: Extract and transpose specific cell data from multiple files

    OK so numptiness # 1
    [Set wsMaster = ThisWorkbook.Sheets("Master") 'sheet report is built into]

    the code doesn't run further than this before the bedug window opens....not sure how to get around this.

    Basically I opened a VBE, dropped your code in, and clicked run......

    Do i need to save the code in a specific file or folder? I did change the address to reflect the specific c:/folder I was aiming for.....but other than that I do not know where else to go to tweak....

    Appreciate your time on this....

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Extract and transpose specific cell data from multiple files

    Quote Originally Posted by Mad-Dog View Post
    Basically I opened a VBE, dropped your code in, and clicked run......
    The parts of the code YOU have to edit are marked in red. The code is commented so you know what each line of code is doing, so the red lines are explained as well.

  9. #9
    Registered User
    Join Date
    07-31-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: Extract and transpose specific cell data from multiple files

    OK...I think I have cottoned onto a thing or two and seem to have progressed abit but still get the debug window when I get to [NR = WorksheetFunction.Match(fName, .Range("Z:Z"), 0)]

    By my deduction the code is looking for a fname called "Rate Card"? Am I right?....

    Basically the files in the folder are named by Vendor and contain a tab (Sheet1) called "Cover Page". It's from this sheet that I wish to extract the data (B15, B19,...etc) of specific cells and transpose them into row within a "Master" sheet (or blank/new workbook) which is what I think you are referring to in your code...

    Sorry if I'm being a pain but really am lost in some of this stuff.......

  10. #10
    Registered User
    Join Date
    07-31-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: Extract and transpose specific cell data from multiple files

    Hope this attachment helps??

    Basically I have circa. 2,000 files similar to the one I have attached and the folder will grow.....So I am looking to extract the data in the "Cover Page" tab cells highlighted in YELLOW into a new "Master" single spreadsheet (a list of the folder).

    So in the "Cover Page" tab they are in a column but in the report of all the files in the folder the data would obviously need to be in a ROW per file in the folder.

    Am I making sense? I feel that your code looks good and will work but it's likely I am fluffing the minor tweak it needs....

    Here is an updated file that I am trying to extract the data from....YELLOW tab is what the output should look like in a separate file. Green tab (Cover Page) is where I am trying to extract the data from....All the files in the folder will be named differently, however, have the same format i.e 3 tabs

    Would be great to be able to open a blank workbook, select the macro, that then asks to select the folder and run it....and bob's your uncle out pops a report with 2,000+ rows of data extracted as per the YELLOW tab called example..

    Your perseverance will be greatly appreciated..

    Happy to Skype if you agree and are willing...
    Attached Files Attached Files
    Last edited by Mad-Dog; 01-16-2014 at 08:47 PM. Reason: Provide example file

  11. #11
    Registered User
    Join Date
    07-31-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: Extract and transpose specific cell data from multiple files

    BTW I'm getting an error/debug message here [NR = WorksheetFunction.Match(fName, .Range("Z:Z"), 0)] now

    Happy to Skype if you are open to me contacting you?

  12. #12
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Extract and transpose specific cell data from multiple files

    Macro updated, YOU still need to make sure the name of your actual consolidation worksheet is named properly under wsMaster = ......
    And you need to make sure you put in the correct fPath to the folder on your system where the files will be found. I saw no macro in your workbook so no idea if you understand these edits or not.

    I've expanded the macro to copy all 15 supplier cells, so all data will be collected now if it exists. Fixed the error you were seeing, too.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    07-31-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: Extract and transpose specific cell data from multiple files

    Awesome....works like a charm. Thank you so much.

+ 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: 0
    Last Post: 07-11-2013, 02:08 AM
  2. Extract specific column data from specific sheet from multiple files in a folder
    By piggyfox in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 05-31-2013, 11:51 AM
  3. [SOLVED] Need Help for creating a Macro to extract specific data from all files in a folder.
    By shaiq123 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-10-2013, 02:08 PM
  4. Use VBA to extract data from multiple files
    By JCHC in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-19-2013, 12:03 PM
  5. Macro to extract data from multiple workbooks, specific sheet, specific cells
    By crissandraauree in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-29-2012, 03:54 PM

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