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!
Last edited by KaitMacN; 08-31-2011 at 08:27 AM.
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
Last edited by barryleajo; 08-30-2011 at 04:35 PM. Reason: PS added
Thats great! Thank you!!
What would the code be so that the search looks in another workbook rather than another sheet? Do I just change what ws2 is?
Hi KaitMacN
Yes - exactly right.
Assuming the second workbook is called "Book2" with the same named worksheet it would look like:
I believe both workbooks need to be open.Set ws2 = Workbooks("Book2").Worksheets("Sample data")
BTW thanks for the feedback.
Barry
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\
Any thoughts?fndrow = ws2.Range("a4:A5000").Find(what:=dte, after:=ws2.Range("A4"), _ LookIn:=xlFormulas, lookat:=xlWhole, searchorder:=xlByColumns, searchdirection:=xlPrevious).Row
I have kept all the parameters the same between the documents
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks