+ Reply to Thread
Results 1 to 27 of 27

Combine multiple spreadsheets in survey format into one database

  1. #1
    Registered User
    Join Date
    11-30-2011
    Location
    West Yorkshire, England
    MS-Off Ver
    Excel 2003
    Posts
    14

    Combine multiple spreadsheets in survey format into one database

    Dear all,

    I have a problem facing me, which I would have imagined to be quite a common problem but despite ruthlessly Googling for nearly an hour I have found no solution, so apologies if this has already been answered in another thread.

    My problem is that I have inherited multiple excel spreadsheets that have been used as surveys, and I need to consolidate these into a database.

    For example;
    'Survey 00001.xls' has 30 different cells where users have input information. These input cells are not in a set structure throughout the individual surveys, e.g. the first two input cells are B5 and then E5, then the next 6 are B8, C8, D8, E8, F8, G8. And so on.

    Aesthetically it's marvellously lain out however now that I am faced with the task of extrapolating all of these fields from all of the worksheets that I have into one database I am increasingly less impressed with the template.

    The positive thing is that ALL of the documents that I need to process are in exactly the same format. I am using Excel 2003, and don't have access to Access.

    Many thanks in advance, and I look forward to a lovely solution to my not so lovely problem!

    Kind regards,

    Chris
    Last edited by ChrisSoulier; 12-02-2011 at 08:15 AM. Reason: Got told off by 'RoyUK'

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Possible VBA trickery required

    Can you post a sample workbook of the current layout and how you want it laid out in your db spreadsheet?

  3. #3
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Possible VBA trickery required

    hi Chris, can you post couple of workbooks with surveys for consolidation and a master workbook with the result you need to obtain?

  4. #4
    Registered User
    Join Date
    11-30-2011
    Location
    West Yorkshire, England
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Possible VBA trickery required

    Hi Kyle123, thanks for your swift repsonse.

    Of course, I have attached examples of the survey form and the format of the export that I would like.

    Is there anything else that you need me to provide?
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    04-02-2010
    Location
    Toronto
    MS-Off Ver
    Excel 2007
    Posts
    62

    Re: Possible VBA trickery required

    Hi Chris,

    I had a similiar problem and found Jerry Beaucaire's webiste to be extremely useful and the comments are easy to follow to modify to your liking.

    https://sites.google.com/a/madrocket...s-to-one-sheet

  6. #6
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Possible VBA trickery required

    give this a whirl, it goes in a standard module in the DB workbook.

    To use it create a folder with all the surveys in and then change the path at the top of the module to the location that you have saved the surveys in. Make sure that only surveys are in the folder

    Please Login or Register  to view this content.

  7. #7
    HelpfulHarry1
    Guest

    Re: Combine multiple spreadsheets in survey format into one database

    I have to agree with Roy.

    please read the forum rules from now on.

  8. #8
    HelpfulHarry1
    Guest

    Re: Combine multiple spreadsheets in survey format into one database

    Oops, damn autofill. x
    Last edited by HelpfulHarry1; 11-30-2011 at 01:14 PM.

  9. #9
    Registered User
    Join Date
    11-30-2011
    Location
    West Yorkshire, England
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Combine multiple spreadsheets in survey format into one database

    Thanks Kyle123, but I am struggling to get this to work.

    I have followed the instructions carefully and it doesn't seem to be doing anything at all.

    Am I missing something?

  10. #10
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Combine multiple spreadsheets in survey format into one database

    Hi Chris, do you get an error at all? Also have you included the slash at the end of the directory?

  11. #11
    Registered User
    Join Date
    11-30-2011
    Location
    West Yorkshire, England
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Combine multiple spreadsheets in survey format into one database

    Hi Kyle,

    Yes I have put a slash at the end of the directory path, the error message reads;

    "'SurveyABC123.xls' could not be found. Check the spelling of the file name, and verify that the file location is correct."

    Thanks

    *Edit* - When I click debug it is highlighting 'With Workbooks.Open(MyFile)' in yellow.
    Last edited by ChrisSoulier; 12-01-2011 at 05:19 AM. Reason: Added extra information

  12. #12
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Combine multiple spreadsheets in survey format into one database

    Please Login or Register  to view this content.
    The only thing you have to adapt is the path.
    Always end the path with a backslash.
    Last edited by snb; 12-01-2011 at 07:16 AM.



  13. #13
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Combine multiple spreadsheets in survey format into one database

    @snb nice code but a few typos

    If you hover over MyFile while it is highlighted, it will give you the full filepath. See if you can open this file, this is a bit odd, I can't think of why you'd be getting this error

  14. #14
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Combine multiple spreadsheets in survey format into one database

    @kyle123

    Which typos ?

  15. #15
    Registered User
    Join Date
    11-30-2011
    Location
    West Yorkshire, England
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Combine multiple spreadsheets in survey format into one database

    Hi Kyle,

    When I hover over 'FolderPath' it gives me the correct directory, but when I hover over 'MyFile' it just gives me the filename rather than the directory+filename.

    One of my objectives of posting the question was not just to get a solution, but to understand the code behind the solution. I know that it's extra work for you, but would you be able to explain the code a little so that I can adapt it if needs be. I would be very appreciative and it might help me to make it work.

    Thanks in advance.

  16. #16
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Combine multiple spreadsheets in survey format into one database

    @snb, you fixed the .End and:
    Please Login or Register  to view this content.
    should be:
    Please Login or Register  to view this content.

  17. #17
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Combine multiple spreadsheets in survey format into one database

    Try this:

    Please Login or Register  to view this content.
    If you want a good description of the Dir() function, have a look here http://www.hobbub.com/vba-vb-vsto/it...-directory-vb/


    snb's concise code works in a similar way, is faster, but slightly less flexible as it relies on the data being structured in a specific way.
    Last edited by Kyle123; 12-01-2011 at 06:13 AM.

  18. #18
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Combine multiple spreadsheets in survey format into one database

    hi, ChrisSoulier, please check attachment, run code "test"
    Attached Files Attached Files

  19. #19
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Combine multiple spreadsheets in survey format into one database

    @Kyle123

    Thanks for 'close reading'. I restored my previous code.
    I think the main advatage of my approach is that the result will be written into the worksheet in 1 go, reducing writing processes to the minimum.

    @watersev

    Can you do us mortals the favour of posting the code in your reply, apart from the attachment ? So we will be able to assess your approach at first glance without having to open the attachment.

  20. #20
    Registered User
    Join Date
    11-30-2011
    Location
    West Yorkshire, England
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Combine multiple spreadsheets in survey format into one database

    @Kyle123 - I've got it to work for the examples that I sent across, (exciting stuff!) now I need to adapt it to my problem. I couldn't send across the exact templates I was using because of company policy conflicts etc. (red tape nonsense). But with your notes this should be fairly straight forward for me to do. Thank you very much for your solution.

    @snb - Thanks for posting a solution, I will be trialling your solution as well, disecting the code and trying to understand it all!

    @watersev - Thanks for posting a response, I will be having a look at the code provided and having a play with it.

    Thanks to everyone, it has been a warm welcome to a new forum. I will be testing the spreadsheets and as soon as I have a result, I will tag this thread as solved and relay my appreciation through reputation!

  21. #21
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Combine multiple spreadsheets in survey format into one database

    Glad it's working

    Only thing to be aware of is to increase the size of the array and loop to cope with the number of fields you are importing

  22. #22
    Registered User
    Join Date
    11-30-2011
    Location
    West Yorkshire, England
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Combine multiple spreadsheets in survey format into one database

    Thanks Kyle123, I've got almost all of it working. Thanks for providing your notes I wouldn't have been able to do it without them.

    There is one last thing that doesn't seem to be working, one of the cells that I am trying to copy from is throwing up this error message; "Run-time error '1004': Application-defined or object-defined error".

    Then the debugger is highlighting the following line of code;

    Please Login or Register  to view this content.

    The only difference between this cell and all the other cells, is that within this cell, a lot of the information has been split with carriage returns within the cell (e.g. by pressing ALT+ENTER). If you were to copy it from within the cell and paste it normally then it would split it onto several rows. The way of getting around this manually is to enter the target cell and then paste. Is this something that can be incorporated?

    Does that all make sense? I can upload examples of what I mean if necessary.

    Thanks in advance.

  23. #23
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Combine multiple spreadsheets in survey format into one database

    If you could upload an example, that would be great

  24. #24
    Registered User
    Join Date
    11-30-2011
    Location
    West Yorkshire, England
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Combine multiple spreadsheets in survey format into one database

    Sorted it, some of the surveys had been saved as 2007.

    I changed
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    Seems to have worked.

    Thanks everyone for all of your help on this. Especially Kyle123.
    Last edited by ChrisSoulier; 12-02-2011 at 08:14 AM. Reason: Messed up the CODE tags

  25. #25
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Combine multiple spreadsheets in survey format into one database

    Glad you've got it sorted. Please mark your thread as solved

  26. #26
    Registered User
    Join Date
    05-09-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: Combine multiple spreadsheets in survey format into one database

    Quote Originally Posted by Kyle123 View Post
    Try this:

    Please Login or Register  to view this content.
    If you want a good description of the Dir() function, have a look here http://www.hobbub.com/vba-vb-vsto/it...-directory-vb/


    snb's concise code works in a similar way, is faster, but slightly less flexible as it relies on the data being structured in a specific way.
    Kyle,

    I was going through this thread and tried using the code, but I keep getting an error. I TRULY NEED YOUR HELP!

    I attached the 1 survey and 1 database spreadsheet. I will be receiving about 100 of these surveys (there will be more questions added) and want to be able to combine all of the answers on to the database.

    Can you assist? I can't seem to get it to work... Sorry I'm a Newbie when it comes to VBA.

    Thanks,

    Valeri
    Attached Files Attached Files
    Last edited by feistyrebel; 05-10-2013 at 06:55 PM.

  27. #27
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,610

    Re: Combine multiple spreadsheets in survey format into one database

    feistyrebel, Welcome to the Forum.

    1. Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.

    2. Your post does not comply with Rule 12 of our Forum RULES. Don't quote whole posts -- it's just clutter. If you are responding to a post out of sequence, limit quoted content to a few relevant lines that makes clear to whom and what you are responding.
    Ben Van Johnson

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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