+ Reply to Thread
Results 1 to 8 of 8

VBA extract sheet data from multiple subfolders into master

  1. #1
    Forum Contributor
    Join Date
    02-25-2013
    Location
    Colorado, US
    MS-Off Ver
    Microsoft 365 Apps
    Posts
    518

    VBA extract sheet data from multiple subfolders into master

    Hello all. I've been searching for several days and trying different techniques with no apparent success, so I'm hoping someone can see what I have and have a better solution. The most comprehensive, succinct, and successful code I've been able to construct with the help of many, is the example below, however, the code doesn't look in subfolders and there are a couple of tweaks that I haven't been able to configure.

    I've attached an example data set. The data sets are ASCII coded (basically you can see all data is read within column 1). All data are space delimited. The header information can remain intact, but once transferred it needs to autofill to lastrow of each relative data set. I've got some code that can delimit out data sets and remove the ASCII headers, so I think I can deal with delimiting it after all the files are transferred, but why isn't it looping through the sub-directories?
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by terriertrip; 09-12-2017 at 08:09 PM.

  2. #2
    Forum Contributor
    Join Date
    02-25-2013
    Location
    Colorado, US
    MS-Off Ver
    Microsoft 365 Apps
    Posts
    518

    Re: VBA extract sheet data from multiple subfolders into master

    a humble 'bump'

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: VBA extract sheet data from multiple subfolders into master

    Hello terriertrip,

    The problem was not the subfolders. It was the data was overwriting itself.

    This macro solves the problem and works much faster since no workbook is being opened to parse the data.

    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Forum Contributor
    Join Date
    02-25-2013
    Location
    Colorado, US
    MS-Off Ver
    Microsoft 365 Apps
    Posts
    518

    Re: VBA extract sheet data from multiple subfolders into master

    Thank you so much Leith for your reply. I'm sorry I haven't been able to test the code yet. I got pulled to another direction yesterday. I will give it a go before I leave work today. If it does work **fingers crossed**, I'll let you know. I'm not sure how long it would take once it executes, so I'll let it run overnight. There's probably several hundred files it has to pull with sets of 15k x 110 data. It's all going into an ADB after compilation. I'll keep you posted.

  5. #5
    Forum Contributor
    Join Date
    02-25-2013
    Location
    Colorado, US
    MS-Off Ver
    Microsoft 365 Apps
    Posts
    518

    Re: VBA extract sheet data from multiple subfolders into master

    Hi Leith. Code doesn't error, but nothing happens. I tested it on several different paths that contained sample files and nothing happens. If I give a bogus path, it errors there but otherwise doa. The code is in a module and I'm running it from there. Any suggestions?

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: VBA extract sheet data from multiple subfolders into master

    Hello terriertrip,

    One 2 reasons I can think of that would cause that behaviour. Either there are no subfolders in the folder "Z:\Operations\Chupacabra\Data\" or there are no files in the subfolders whose names match "*dq1000d.las*". I tested the macro by creating a couple of subfolders and adding in your file and modifying the copies to tell them apart. everything worked on my end. I did the test on my "C" drive and one of my network folders. It was all good.

  7. #7
    Forum Contributor
    Join Date
    02-25-2013
    Location
    Colorado, US
    MS-Off Ver
    Microsoft 365 Apps
    Posts
    518

    Re: VBA extract sheet data from multiple subfolders into master

    Hmmm. There are definitely subfolders and there are 2-3 files within different files named dq1000d.las. Like I said, I tried on both my local drive and our network drive to test it before attempting the entire directory. I have other routines that call files up on the network drive, so it isn't an issue of security. Since it's working on your end, the only thing I can think of is, is there a reference that I may not have enabled within my vba tools menu? Is there some sort of error handling that I could implement to step through the code? Microsoft Scripting Runtime enabled. I'm running Excel 2016 on windows 10. Code looks good. Totally stumped.
    Last edited by terriertrip; 09-15-2017 at 01:42 AM.

  8. #8
    Forum Contributor
    Join Date
    02-25-2013
    Location
    Colorado, US
    MS-Off Ver
    Microsoft 365 Apps
    Posts
    518

    Re: VBA extract sheet data from multiple subfolders into master

    One thing that occured to me, the file I attached was a text file - only because EF wouldn't allow the attachment of the file in it's native format. I changed the extention to (*.txt) to upload. The actual file is an industry specific Log ASCII Standard format. (*.las). Could there be a conflict? Although, I changed the files to (*.txt) along with the IfThen code, but still just a flicker and a blank ws. sigh...

+ 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. Extract/present data from master sheet
    By DJSorg in forum Excel General
    Replies: 1
    Last Post: 05-24-2016, 11:06 AM
  2. Replies: 3
    Last Post: 05-07-2014, 11:05 AM
  3. Extract data based on variables from multiple subfolders
    By honeybunny in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-28-2013, 09:56 AM
  4. Replies: 4
    Last Post: 03-05-2013, 01:02 PM
  5. Replies: 3
    Last Post: 01-05-2013, 02:20 AM
  6. Extract data into master work sheet
    By kammariarun in forum Excel General
    Replies: 0
    Last Post: 12-11-2011, 03:53 PM
  7. Extract data from multiple workbooks to master
    By unley in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-24-2010, 06:22 AM

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