Consulting

Results 1 to 6 of 6

Thread: How can I create a Vlookup to certain columns in a closed workbook?

  1. #1
    VBAX Newbie
    Joined
    Feb 2008
    Posts
    5
    Location

    How can I create a Vlookup to certain columns in a closed workbook?

    I currently have a master file with data and copy copy my master file over 17 other excel files to update them monthly. How can I create a Vlookup from each separate file to the columns of data that I need in the master file even when the master file is closed?

    Thanks for the help.

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Heather
    Welcome to VBAX
    Sorry, I don't understand the question.
    Regards
    MD
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,064
    Location
    Hi MD, I believe that HeatherA is trying to reference data in a closed Workbook (Master) when working in any one of the 17 workbooks that she is trying to update monthly.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  4. #4
    VBAX Tutor
    Joined
    Nov 2007
    Posts
    228
    Location
    Hi HeatherA,

    MD and xld helped me with the code below which enables me to gather VLOOKUP data from an unopened file

    [vba]
    Private Sub AddVlookUp()
    Const FILEPATH As String = _
    "Place your filepath here for the Vlookup data"
    Dim i As Long
    Dim k As Long
    Dim LastRow As Long

    With Sheets("Place Sheet Name here")
    For i = 1 To 3

    For k = 1 To 125

    .Cells(k, i).FormulaR1C1 = "='" & FILEPATH & _
    "[Place your Workbook name here.xls]Place Sheet Name here'!R" & k & "C" & i
    Next
    Next
    End With
    End Sub
    [/vba]
    i is your column references (1 to 3 as above = A, B & C)
    k is your row reference (1 to 125 as above)

    This should help you

    Marshybid

  5. #5
    VBAX Newbie
    Joined
    Feb 2008
    Posts
    5
    Location

    Clarification of my question...

    Maybe I didn't explain it well the first time. I have 18 workbooks with basically the same data. 1 is a master file that I update monthly and the other 17 are for each of the 17 people I work with. Currently i have to update the master file and then copy the data into the other 17 files to update them with the new data. I would like to be able to just update the master file and have the other 17 automatically update.

    The problem I ran into with my Vlookup is that it only works when the master file is open, however most of the time the file is closed. Can anyone suggest code that will make this work? I tried the code that Marshybid gave but it didn't work.

    Thanks!
    Heather

  6. #6
    Will this work?
    I'm running Excel 2003 and it can reference it my file without forcing it to be open.

    [vba]VLOOKUP(C18,'\\Network-folder name\sub-folder-name\[Name-of-file-to-look-in.xls]sheet-name'!$C$45:$D$56[/vba]
    of course the cell addresses would need to be changed to suit your needs.

    Rolly

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •