+ Reply to Thread
Results 1 to 6 of 6

Find function in Macro between different workbooks

  1. #1
    Registered User
    Join Date
    08-03-2011
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2003
    Posts
    22

    Find function in Macro between different workbooks

    I am trying to use a macro that will look at a date that I enter and find that date adn corresponding data in a different workbook.

    For simplicity sake I have included a sample of data in an attachment but in the same workbook for now!

    On "Sample Calendar" tab I want to be able to change that date and have it search for that date to fill in the blanks for Breakfast, Lunch and Dinner for the three week section (in theory)

    Any and all help is greatly appreciated!
    Attached Files Attached Files
    Last edited by KaitMacN; 08-31-2011 at 08:27 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    06-19-2010
    Location
    Holywell, N Wales, UK
    MS-Off Ver
    Excel 2013
    Posts
    470

    Re: Find function in Macro between different workbooks

    Hi KaitMacN
    Perhaps adapt the attached?
    Note that I have extended your range of 'lookup' dates.
    Run the macro called "fndate"
    Barry

    PS You will need to add some error checking for if the date isn't found
    Attached Files Attached Files
    Last edited by barryleajo; 08-30-2011 at 04:35 PM. Reason: PS added

  3. #3
    Registered User
    Join Date
    08-03-2011
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: Find function in Macro between different workbooks

    Thats great! Thank you!!

  4. #4
    Registered User
    Join Date
    08-03-2011
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: Find function in Macro between different workbooks

    What would the code be so that the search looks in another workbook rather than another sheet? Do I just change what ws2 is?

  5. #5
    Valued Forum Contributor
    Join Date
    06-19-2010
    Location
    Holywell, N Wales, UK
    MS-Off Ver
    Excel 2013
    Posts
    470

    Re: Find function in Macro between different workbooks

    Hi KaitMacN
    Yes - exactly right.
    Assuming the second workbook is called "Book2" with the same named worksheet it would look like:
    Please Login or Register  to view this content.
    I believe both workbooks need to be open.
    BTW thanks for the feedback.
    Barry

  6. #6
    Registered User
    Join Date
    08-03-2011
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: Find function in Macro between different workbooks

    WHen I am trying to apply this macro into my actual workbook (even without linking two a second, literally cut and paste) it is giving me an error of:
    runtime error '91':
    object variable or with block variable not set

    and the part of the code that is being higlighted is\

    Please Login or Register  to view this content.
    Any thoughts?
    I have kept all the parameters the same between the documents

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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