+ Reply to Thread
Results 1 to 28 of 28

help with vba/macro for vlookup from multiple files to one file

  1. #1
    Registered User
    Join Date
    10-30-2014
    Location
    cluj, romania
    MS-Off Ver
    ms office 2010
    Posts
    15

    help with vba/macro for vlookup from multiple files to one file

    Hi,

    i'm trying to make a report that will show shortages for materials, and i want to do this as easy as possible

    i have attached the shortage report, and bom1 and bom2 files for better understanding

    what i want to do is, make a macro/vba that will make vlookup in "shortage report" file for each new bom file i copy in location D:\shortage

    right now i have 2 bom files, but there will be many more to come ...

    i really don't know where to start. any support is welcome

    if you have any questions, please let me know
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    09-11-2013
    Location
    Germany
    MS-Off Ver
    Excel 2007
    Posts
    265

    Re: help with vba/macro for vlookup from multiple files to one file

    In the Shortage report, will the bom list in row 4 befilled in when the bom is put in the folder or will the fields be filled out before a bom exists..

    i.e. when a bom is added to the folder, the macro would check if it exists in the report, if not it would enter all the details?

    OR

    Headings bom1 ----bom1000 are already filled in and the qty is added when the file is placed in the folder.

  3. #3
    Registered User
    Join Date
    10-30-2014
    Location
    cluj, romania
    MS-Off Ver
    ms office 2010
    Posts
    15

    Re: help with vba/macro for vlookup from multiple files to one file

    [QUOTE=JRidge;3885236]In the Shortage report, will the bom list in row 4 befilled in when the bom is put in the folder or will the fields be filled out before a bom exists..

    i.e. when a bom is added to the folder, the macro would check if it exists in the report, if not it would enter all the details?

    QUOTE]

    correct

    row 4 should be filled with the bom file names when i add another bom file in location D:\shortage location( i.e., if i add a "bom3.xls" file in the location, the macro should populate cell "N4" in shortage report with the file name, in this case "bom3.xls", "bom4.xls" in cell "O4", "bom5.xls" in cell "P4" and so on )

    best regards

  4. #4
    Forum Contributor
    Join Date
    09-11-2013
    Location
    Germany
    MS-Off Ver
    Excel 2007
    Posts
    265

    Re: help with vba/macro for vlookup from multiple files to one file

    Ok. am playing with it..

    will the bom always be in the same format? like the examples.

  5. #5
    Registered User
    Join Date
    10-30-2014
    Location
    cluj, romania
    MS-Off Ver
    ms office 2010
    Posts
    15

    Re: help with vba/macro for vlookup from multiple files to one file

    yes, it will always have the data that needs to be pulled from the same column

  6. #6
    Forum Contributor
    Join Date
    09-11-2013
    Location
    Germany
    MS-Off Ver
    Excel 2007
    Posts
    265

    Re: help with vba/macro for vlookup from multiple files to one file

    Well this should be fun

    Try this out.

    Put all files in your D:\shortage\ folder
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    10-30-2014
    Location
    cluj, romania
    MS-Off Ver
    ms office 2010
    Posts
    15

    Re: help with vba/macro for vlookup from multiple files to one file

    just wow :D, thank you very much, that is great!

    now, i've been playing a little with it and i missed some things

    There will be cases when i'll have the same component multiple times in the same bom, like in the attachment, so i'll need to have the sum for that component vlookup in shortage report
    And there will be boms that will have the file name different. Containing characters like"(" or ")" ....

    bom100(1).xlsx

    many thanks
    Last edited by sacerdot; 11-01-2014 at 02:58 AM.

  8. #8
    Forum Contributor
    Join Date
    09-11-2013
    Location
    Germany
    MS-Off Ver
    Excel 2007
    Posts
    265

    Re: help with vba/macro for vlookup from multiple files to one file

    Hi sacerdot,

    Probably the code could be a lot neater and compact, I am just learning Vba and no expert so i don't no all the shortcuts etc.

    Maybe some expert on here will have a look at what i have done and say there is an easier way to do it

    Anyway, bom100.xlsx has all individual components and no repeated.

    I take it you mean component "a" could be repeated a number of times in Column A......?

  9. #9
    Registered User
    Join Date
    10-30-2014
    Location
    cluj, romania
    MS-Off Ver
    ms office 2010
    Posts
    15

    Re: help with vba/macro for vlookup from multiple files to one file

    hi JRidge,

    first of all, thank you for your support, you are doing really great

    i have edited my previous reply and reattached the file, as i uploaded the wrong file ... but yes, you understood my point right

  10. #10
    Forum Contributor
    Join Date
    09-11-2013
    Location
    Germany
    MS-Off Ver
    Excel 2007
    Posts
    265

    Re: help with vba/macro for vlookup from multiple files to one file

    Ok, I will have a look and get Back to you

  11. #11
    Registered User
    Join Date
    10-30-2014
    Location
    cluj, romania
    MS-Off Ver
    ms office 2010
    Posts
    15

    Re: help with vba/macro for vlookup from multiple files to one file

    thank you :D, anyway, this is not anything urgent, so take your time, enjoy the weekend, etc.

  12. #12
    Forum Contributor
    Join Date
    09-11-2013
    Location
    Germany
    MS-Off Ver
    Excel 2007
    Posts
    265

    Re: help with vba/macro for vlookup from multiple files to one file

    In the bom is there any other data in the other columns?

  13. #13
    Registered User
    Join Date
    10-30-2014
    Location
    cluj, romania
    MS-Off Ver
    ms office 2010
    Posts
    15

    Re: help with vba/macro for vlookup from multiple files to one file

    yes, there will be, but it can be deleted(or i can delete it ), i don't need anything else except component (column "A") and quantity (column "H" )

  14. #14
    Forum Contributor
    Join Date
    09-11-2013
    Location
    Germany
    MS-Off Ver
    Excel 2007
    Posts
    265

    Re: help with vba/macro for vlookup from multiple files to one file

    Thats Good, Will try something and get back to you

  15. #15
    Forum Contributor
    Join Date
    09-11-2013
    Location
    Germany
    MS-Off Ver
    Excel 2007
    Posts
    265

    Re: help with vba/macro for vlookup from multiple files to one file

    Try This:

    Fully Test and let me know
    Attached Files Attached Files

  16. #16
    Registered User
    Join Date
    10-30-2014
    Location
    cluj, romania
    MS-Off Ver
    ms office 2010
    Posts
    15

    Re: help with vba/macro for vlookup from multiple files to one file

    i just tested it and works perfect, just what i wanted.

    many many thanks!!!!

    now, can the macro also clean the boms? everything that is not on column "A" and "H" to be deleted. if this is too much, i can just do it manually

  17. #17
    Forum Contributor
    Join Date
    09-11-2013
    Location
    Germany
    MS-Off Ver
    Excel 2007
    Posts
    265

    Re: help with vba/macro for vlookup from multiple files to one file

    Yep, I was thinking that aswell....

    But as the Macro doesn''t actually save a new copy of the bom it doesnt need to clean it.

    If i am right the Macro to sort and then Combine Duplicates in the bom will just overwrite columns B and I with the new List and Figures, Once it has the Copied it to the Shortage Report, It closes the bom without saving the changes...

    Try it... Make a new bom say bom14, fill in column B and I with anything in the rows that have components in A..

  18. #18
    Forum Contributor
    Join Date
    09-11-2013
    Location
    Germany
    MS-Off Ver
    Excel 2007
    Posts
    265

    Re: help with vba/macro for vlookup from multiple files to one file

    Yeah no need to Clean the bom...

    The Macros and Code do everything that is required.

  19. #19
    Registered User
    Join Date
    10-30-2014
    Location
    cluj, romania
    MS-Off Ver
    ms office 2010
    Posts
    15

    Re: help with vba/macro for vlookup from multiple files to one file

    just tested and you are right.

    i also tried to add another file that doesn't contain the "bom" word. can the macro work on any file that i put in the folder except the shortage report file?

  20. #20
    Forum Contributor
    Join Date
    09-11-2013
    Location
    Germany
    MS-Off Ver
    Excel 2007
    Posts
    265

    Re: help with vba/macro for vlookup from multiple files to one file

    Quote Originally Posted by sacerdot View Post
    just tested and you are right.

    i also tried to add another file that doesn't contain the "bom" word. can the macro work on any file that i put in the folder except the shortage report file?
    Examples of File Names would be too much...

    Would all files have the same setup inside..ie. Like the bom contents..

  21. #21
    Registered User
    Join Date
    10-30-2014
    Location
    cluj, romania
    MS-Off Ver
    ms office 2010
    Posts
    15

    Re: help with vba/macro for vlookup from multiple files to one file

    the files names could be anywhere from 12 digit number to a combination of 20-40 letters and numbers...so probably any kind of combination possible

    the setup inside is the same for all files, ( component on column A, quantity on column H, and all sort of details that i'm not interested on the rest of the column/rows )

  22. #22
    Registered User
    Join Date
    10-30-2014
    Location
    cluj, romania
    MS-Off Ver
    ms office 2010
    Posts
    15

    Re: help with vba/macro for vlookup from multiple files to one file

    i tried changing the directory for the bom files ( with different name combinations) to be separate from the shortage report, and vlookup works ok if the boms are clean ( details only on column A and H )...if there is info also on other column/rows, vlookup gathers different data

  23. #23
    Registered User
    Join Date
    10-30-2014
    Location
    cluj, romania
    MS-Off Ver
    ms office 2010
    Posts
    15

    Re: help with vba/macro for vlookup from multiple files to one file

    Quote Originally Posted by sacerdot View Post
    i tried changing the directory for the bom files ( with different name combinations) to be separate from the shortage report, and vlookup works ok if the boms are clean ( details only on column A and H )...if there is info also on other column/rows, vlookup gathers different data
    actually the vlookup works ok if any other bom files are closed, if i have one of the bom file also open, and i click on the import bom button from shortage report file, the vlookup gathers different data and overwrites the other boms also...does this make sense?

  24. #24
    Registered User
    Join Date
    10-30-2014
    Location
    cluj, romania
    MS-Off Ver
    ms office 2010
    Posts
    15

    Re: help with vba/macro for vlookup from multiple files to one file

    nevermind )...i was just not using the macro right

    Thanks again JRidge. This is exactly what i needed!!!

    no need for any changes.

  25. #25
    Forum Contributor
    Join Date
    09-11-2013
    Location
    Germany
    MS-Off Ver
    Excel 2007
    Posts
    265

    Re: help with vba/macro for vlookup from multiple files to one file

    1. With the opening any file, it would be best to move the boms etc to a different folder.

    Make a new Folder in the Shortage Folder Called "bom"

    2. In the shortage folder only have the Shortage report.

    3. In the bom folder only put in files which meet the criteria of the bom files (Doesn't matter what they are called).

    4. Use this code:
    Attached Files Attached Files

  26. #26
    Registered User
    Join Date
    10-30-2014
    Location
    cluj, romania
    MS-Off Ver
    ms office 2010
    Posts
    15

    Re: help with vba/macro for vlookup from multiple files to one file

    just tested and worked excelent! just what i wanted.

    many thanks JRidge!!!

  27. #27
    Forum Contributor
    Join Date
    09-11-2013
    Location
    Germany
    MS-Off Ver
    Excel 2007
    Posts
    265

    Re: help with vba/macro for vlookup from multiple files to one file

    Perfect.

    If the Solution is what you wanted the please mark this thread as solved. (Top of Thread, under "Thread Tools").

    Also if you think i helped Please don't forget to add reputation using the * in one of my posts..

    Regards

    JRidge

  28. #28
    Registered User
    Join Date
    10-30-2014
    Location
    cluj, romania
    MS-Off Ver
    ms office 2010
    Posts
    15

    Re: help with vba/macro for vlookup from multiple files to one file

    done that. thanks again

+ 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] Macro to merge multiple excel files with same tab name into one file
    By Ardiko in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-16-2013, 04:53 PM
  2. Macro to send data from one file to multiple other existing files
    By masben in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-09-2013, 05:21 AM
  3. Replies: 0
    Last Post: 11-27-2012, 01:43 PM
  4. VLOOKUP multiple files: Formula? Macro? Other?
    By mhedges in forum Excel General
    Replies: 3
    Last Post: 07-05-2012, 07:08 PM
  5. Apply macro to multiple CSV files and then convert to XLS or TXT file,
    By asok in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-24-2012, 10:13 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