+ Reply to Thread
Results 1 to 17 of 17

Inserting Vlookup function in all workbooks

  1. #1
    Registered User
    Join Date
    02-27-2008
    Posts
    65

    Inserting Vlookup function in all workbooks

    I have around 700 workbooks in a folder on my PC.

    My master file(master database.xlsx) is kept open from which i have to Vlookup the values into these 700 workbooks.

    The "agent Id" column is common in both the master database.xlsx as well as those other workbooks also.

    The thing i want to do is i need the data from the "reporting supervisor" which is in the master database.xlsx file to be available in the G column of the other 700 books ( i have attached only 4 sample books). The G column can be then named as "Reporting Supervisor". Since "Agent ID" is available in both files we can vlookup taking this as a base. I have attached the 4 sample files out of 700 as well as the master database file in a zip file.

    Hope my question is clear to you. Please give a nice solution to this or else i have to open all the 700 files and do vlookup one by one.
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    02-27-2008
    Posts
    65

    Re: Inserting Vlookup function in all workbooks

    Hello, noone can solve this Issue ??? is this so tough ? Plz help if someone can do this easily.

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

    Re: Inserting Vlookup function in all workbooks

    See, once you post up some useful data, it goes quickly. Put this macro into your Master Database program, run it from there. You will need to edit the part I marked in red to the folder you will use each time.

    This macro will run on ALL the files in the folder starting with the "Agent Call Report...." in the name.
    Please Login or Register  to view this content.
    The macro also sorts the Master Database info and gives it a named range.
    Attached Files Attached Files
    Last edited by JBeaucaire; 05-21-2009 at 04:51 AM.
    _________________
    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!)

  4. #4
    Registered User
    Join Date
    02-27-2008
    Posts
    65

    Re: Inserting Vlookup function in all workbooks

    I have pasted this in the module in master database.xlsx

    After running its giving error "Run-time error '445': Object doesn't support this action. when i press debug its comes on here With Application.FileSearch which is marked yellow.

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

    Re: Inserting Vlookup function in all workbooks

    Did you try just running it as is in the workbook attached? I don't believe any of the code I used is non-Excel-2007 friendly, but maybe.

    Edit the workbook I attached to the proper path for your files, or somewhere you have a couple to test on....and run the macro from inside the book I gave you. See if you get better results.

    The macro had no trouble opening your Excel 2007 A"agent" files and updating them, it ran right through the whole bunch of them.

  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: Inserting Vlookup function in all workbooks

    Wait, you can't run a macro in a file called Master Database.xlsx, can you? It has to be named Master Database.xlsm in Excel 2007.

  7. #7
    Registered User
    Join Date
    02-27-2008
    Posts
    65

    Re: Inserting Vlookup function in all workbooks

    I have saved the file in the format .xlsm but i am getting same error. Can you attached the master database file with the code pasted in it ?

  8. #8
    Registered User
    Join Date
    02-27-2008
    Posts
    65

    Re: Inserting Vlookup function in all workbooks

    are you able to do it correctly on your side ? all my other macros run properly even if i dont save them as .xlsm file. Please help me with the solution for this.

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

    Re: Inserting Vlookup function in all workbooks

    Post #3 has had that attachment all along.

  10. #10
    Registered User
    Join Date
    02-27-2008
    Posts
    65

    Re: Inserting Vlookup function in all workbooks

    Oh no same error comes again and after debugging it comes near "With Application.FileSearch" highlighting it in Yellow. Why is this happening ya ?

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

    Re: Inserting Vlookup function in all workbooks

    Good question.
    Last edited by JBeaucaire; 05-21-2009 at 06:42 AM.

  12. #12
    Registered User
    Join Date
    02-27-2008
    Posts
    65

    Re: Inserting Vlookup function in all workbooks

    so i thing my query will remain unsolved and i will have to do manually ? dont tell me.

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

    Re: Inserting Vlookup function in all workbooks

    What did you change the RED sections in that code to?

  14. #14
    Registered User
    Join Date
    02-27-2008
    Posts
    65

    Re: Inserting Vlookup function in all workbooks

    With Application.FileSearch
    .NewSearch
    .LookIn = "E:\New Folder"
    .SearchSubFolders = False
    .Filename = "Agent Call Report*.xlsx"
    .Execute
    I change the folder name to the above mentioned one as my files are in that folder. Rest everything is same. But the macro stops before coming to this line.
    Last edited by luckyros; 05-21-2009 at 11:10 PM.

  15. #15
    Registered User
    Join Date
    02-27-2008
    Posts
    65

    Re: Inserting Vlookup function in all workbooks

    This is what i found on the net..........


    Wednesday, 9 May 2007

    No Application.Filesearch in 2007

    In earlier versions Aplication.FileSearch could be used to loop through all the files contained in a Directory. This does not appear to work in 2007 versions. I have managed to use Dir to achieve this instead.

    --------------------------------------------------------------------------------------' Module : Module1
    ' DateTime : 09/05/2007 08:43
    ' Author : Roy Cox (royUK)' Website : www.excel-it.com for more examples and Excel Consulting
    ' Purpose : Open all worksheets in a specific folder' Disclaimer; This code is offered as is with no guarantees. You may use it in your' projects but please leave this header intact.
    '---------------------------------------------------------------------------------------

    Option Explicit
    Sub Open_All_Files()
    Dim oWbk As Workbook
    Dim sFil As String
    Dim sPath As String

    sPath = "C:\Documents and Settings\Roy Cox\My Documents\" 'location of files
    ChDir sPath
    sFil = Dir("*.xlsx") 'change or add formats
    Do While sFil <> "" 'will start LOOP until all files in folder sPath have been looped through Set oWbk = Workbooks.Open(sPath & "\" & sFil) 'opens the file

    ' do something
    oWbk.Close True 'close the workbook, saving changes
    sFil = Dir
    Loop ' End of LOOP
    End Sub


    Can you change the code according to the example i have given up ? to suit my needs ?
    Last edited by luckyros; 05-21-2009 at 11:11 PM.

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

    Re: Inserting Vlookup function in all workbooks

    Please edit posts #14 and #15 and put CODE tags around your VBA code as per the forum rules. See the "How To.... ....Add Code Tags" at the top menu for instructions if you've never done that.

    I'll take a look when I get back to my office, but I do not use Excel 2007. You could post a new thread with my macro (in between code tags, please) and an appropriate title : "Convert 2003 macro to work with 2007" and I'm sure someone would make quick work of that for you.
    Last edited by JBeaucaire; 05-21-2009 at 01:59 PM.

  17. #17
    Registered User
    Join Date
    04-25-2010
    Location
    Angola
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Inserting Vlookup function in all workbooks

    Hi Guy,

    This code is working nicely,

    regards

+ 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