+ Reply to Thread
Results 1 to 10 of 10

Vlookup with Named ranges

  1. #1
    Forum Contributor
    Join Date
    05-06-2004
    Posts
    117

    Vlookup with Named ranges

    Greetings and thank you in advance for any help provided. I am having problems getting the code below to follow my intentions. I have 2 files. I have a temporary file that holds all the data that I need. I have a destination file that needs to have data copied into it. In the temp file, I have data for several dates and product types. What I intend to do is to do a vlookup in VBA to look for the date and the product type in the temp file and copy the appropriate data to the destination file. I have numerous named ranges both in my temp file and my destination file. For the code below, I wanted to make a loop to find the date in the temp file that is listed in the destination file. Once this is done, I wanted to find the product type in the temp file that is listed in the destination file. If both conditions exist, then copy a certain range from the temp file to the destination file. My intention is evident in the code, but I don’t think that I am putting in the correct “code format”. Can any one help?
    Thank you
    Please Login or Register  to view this content.

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

    I made quite a few changes to your macro. The string variable "Day" has been changed to "D" because Day is a VBA keyword. The loop has been changed to search for all occurances of "Date1" and then perform the copy and paste between the workbooks. The code is more condensed and easier to read. Make a copy of your workbooks before you run the macro. I believe I understood what you wanted to do, but better to error on the safe side.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  3. #3
    Forum Contributor
    Join Date
    05-06-2004
    Posts
    117
    Leith, I appreciate your help. Thank you. However, I have run into a problem running the code. I got a Run-time error '1004':Application-defined or object-defined error and the following part of the code is highlited in yellow:
    Please Login or Register  to view this content.
    Could this error be because, I do not have a named range of "Date1" in the temp file?
    What I figured is that the macro would look at the value of that named range in the destination file and go and find that value in the temp file.
    Also, the dates in the temp files are formulas, does this matter?
    Last edited by Leith Ross; 01-14-2009 at 03:12 PM. Reason: Added Code Tags

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

    There are quite a few possibilities why this is happening. It would be easier and faster for me to troubleshoot the error if you could post the workbook.

    Sincerely,
    Leith Ross

  5. #5
    Forum Contributor
    Join Date
    05-06-2004
    Posts
    117
    Leith, I am trying to attach the 2 files that I would be using. Please note that they have been edited since they are work files. I have just left the bare bones info necessary. Please know that I would be glad to answer any questions in regards to the files if they do not make sense. I really appreciate your willingness to help. Thank you

  6. #6
    Forum Contributor
    Join Date
    05-06-2004
    Posts
    117
    Leith, I keep getting a Database error when trying to attach the files. Is there any way that I can help by answering any questions that you might have?
    I will keep on trying to make the attachements, but I have already tried a few times.

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

    The forum servers are being updated You can email the file to me at LeithRoss@Gmail.com. I'll post the changes and hopefully the updated workbook.

    Sincerely,
    Leith Ross

  8. #8
    Forum Contributor
    Join Date
    05-06-2004
    Posts
    117
    Thank you Leith, I will do that.

  9. #9
    Forum Contributor
    Join Date
    05-06-2004
    Posts
    117
    Leith, just sent out the files to your email. Please feel free to ask any questions -- it is the least that I can do. Thank you

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

    I received both files OK. Thanks.

    Sincerely,
    Leith Ross

+ 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