+ Reply to Thread
Results 1 to 29 of 29

HLookup

  1. #1
    Registered User
    Join Date
    04-14-2011
    Location
    Seattle, Washington
    MS-Off Ver
    Excel 2007
    Posts
    13

    HLookup

    Hello everyone,

    I don't know if I am on the right track here with HLOOKUP, I will explain what I am trying to do.. I have 2 worksheets, one is basically a template of a schedule (blank calendar), the other is a list of activities, with a code for the activity. What I am trying to do is have the schedule populate by searching the worksheet with all the activity information on it and return it to the blank schedule. The problem is this, I could have multiple of the same activities happening the same month so I also need to to search by DATE and let me know if there is a certain activity on a certain date and populate the schedule is anything like this even possible?

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Excel 2007 - Help with hlookup.

    To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    If needed supply a before and after sheet in the workbook so the person helping you can see what you are trying to achieve.

    Doing this will ensure you get the result you need!
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Registered User
    Join Date
    04-14-2011
    Location
    Seattle, Washington
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Excel 2007 - Help with hlookup.

    Ok, sorry about that, here's an example of what I'm trying to achieve. Basically when I enter a course code on sheet 2 under the date, I want it to look at the list of courses in sheet 1 as well as the date and let me know if this course is available on that specific date..
    Attached Files Attached Files

  4. #4
    Forum Contributor bentleybob's Avatar
    Join Date
    02-27-2009
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2010
    Posts
    644

    Re: Excel 2007 - Help with hlookup.

    Here's a solution (works in Excel 2007+).

  5. #5
    Forum Contributor bentleybob's Avatar
    Join Date
    02-27-2009
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2010
    Posts
    644

    Re: Excel 2007 - Help with hlookup.

    Here's an example (works in Excel 2007+).
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    04-14-2011
    Location
    Seattle, Washington
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Excel 2007 - Help with hlookup.

    Very cool! So did you just drop all of the other dates out? I only see 4/14 on sheet1, or did the formula do that? Sorry I am very novice at excel.. Also, if I need to look for multiple courses can I just paste the formula to the cell beneath it again?
    Last edited by mikeM-; 04-14-2011 at 04:06 PM.

  7. #7
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Excel 2007 - Help with hlookup.

    Try:

    =IF(SUMPRODUCT(--(sheet1!$B$85:$B$1590=A4),--(sheet1!$D$85:$D$1590<=A3),--(sheet1!$E$85:$E$1590>=A3)),"Available","Not Available")

    copied across...

    For Xl2007 and later

    =IF(COUNTIFS(sheet1!$B$85:$B$1590,A4,sheet1!$D$85:$D$1590,"<="&A3,sheet1!$E$85:$E$1590,">="&A3),"Available","Not Available")

  8. #8
    Registered User
    Join Date
    04-14-2011
    Location
    Seattle, Washington
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Excel 2007 - Help with hlookup.

    Ok a little confused on =IF(SUMPRODUCT(--(sheet1!$B$85:$B$1590=A4),--(sheet1!$D$85:$D$1590<=A3),--(sheet1!$E$85:$E$1590>=A3)),"Available","Not Available") , when I paste that into the formula bar where do I enter the course code I'm looking for?

  9. #9
    Forum Contributor bentleybob's Avatar
    Join Date
    02-27-2009
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2010
    Posts
    644

    Re: Excel 2007 - Help with hlookup.

    The formula shows a blank if there's no match.

  10. #10
    Registered User
    Join Date
    04-14-2011
    Location
    Seattle, Washington
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Excel 2007 - Help with hlookup.

    Awesome, so bob, if I want to enter a different course code for a different date, do I have to manually go in and filter out the dates? Also - where do I enter the new course code, underneath the date or on the side like you did?

  11. #11
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Excel 2007 - Help with hlookup.

    Quote Originally Posted by mikeM- View Post
    Ok a little confused on =IF(SUMPRODUCT(--(sheet1!$B$85:$B$1590=A4),--(sheet1!$D$85:$D$1590<=A3),--(sheet1!$E$85:$E$1590>=A3)),"Available","Not Available") , when I paste that into the formula bar where do I enter the course code I'm looking for?
    In A4 (just the course code).

    You can enter it elsewhere, but then change the reference to A4 in the formula to match where you entered the course code.

  12. #12
    Registered User
    Join Date
    04-14-2011
    Location
    Seattle, Washington
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Excel 2007 - Help with hlookup.

    That works great!! Thank you! Ok, heres my next question, is it possible to have it display the Activity ID if it comes up "available"?

  13. #13
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Excel 2007 - Help with hlookup.

    There are multiple matches sometimes, it seems? Is that right? If so, then what?

  14. #14
    Registered User
    Join Date
    04-14-2011
    Location
    Seattle, Washington
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Excel 2007 - Help with hlookup.

    Well if there are multiple matches on the same day, this could be correct, sometimes we have more than one of the same course going.. for example one in the morning one in the evening... As long as it just scans within the date provided it's good!

  15. #15
    Forum Contributor bentleybob's Avatar
    Join Date
    02-27-2009
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2010
    Posts
    644

    Re: Excel 2007 - Help with hlookup.

    Just enter the same format ("Course - " plus the ID#) in Column A (I already copied the formulas down through row 20). You can also change the dates if you like. Or, if you want to be able to specify different dates for different courses, use the attached.
    Attached Files Attached Files

  16. #16
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Excel 2007 - Help with hlookup.

    For 6C62890 on 4/14/2011 there are 4 different activities.

  17. #17
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Excel 2007 - Help with hlookup.

    In the interest of eliminating confusion for you since we are going back and forth between 3 of us...... I am going to bow out and let bob finish this off with you.

  18. #18
    Forum Contributor bentleybob's Avatar
    Join Date
    02-27-2009
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2010
    Posts
    644

    Re: Excel 2007 - Help with hlookup.

    I was just going to offer to do the same!

  19. #19
    Registered User
    Join Date
    04-14-2011
    Location
    Seattle, Washington
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Excel 2007 - Help with hlookup.

    That works awesome as well! Thank you guys so much. Bob - is there a way to make it display the activity ID if it's "Available"?

  20. #20
    Forum Contributor bentleybob's Avatar
    Join Date
    02-27-2009
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2010
    Posts
    644

    Re: Excel 2007 - Help with hlookup.

    Yes. But the approach is different using Example 1, where there's only one course you're looking for, versus Example 2 where you have multiple courses. So, which one do you want to use?

    Also, what do you do about multiple matches? Do you only want the Activity # for the first match or do you need them all?

  21. #21
    Registered User
    Join Date
    04-14-2011
    Location
    Seattle, Washington
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Excel 2007 - Help with hlookup.

    Well what I am going to be doing this is for a month, so I could be looking for multiple courses per date. I like example 2, also I would like it to give me activity codes for all the matches it brings up. If there are multiple matches on that day I would like it to bring up all the activity ID's. Once again, thank you so much bob! Here's an example of the calendar..
    Attached Files Attached Files
    Last edited by mikeM-; 04-14-2011 at 05:11 PM.

  22. #22
    Forum Contributor bentleybob's Avatar
    Join Date
    02-27-2009
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2010
    Posts
    644

    Re: Excel 2007 - Help with hlookup.

    I will have to look at this this evening, if you can wait until tomorrow.

  23. #23
    Registered User
    Join Date
    04-14-2011
    Location
    Seattle, Washington
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Excel 2007 - Help with hlookup.

    No problem. Thank you so much for your help Bob!

  24. #24
    Forum Contributor bentleybob's Avatar
    Join Date
    02-27-2009
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2010
    Posts
    644

    Re: HLookup

    Actually, it was easier than I thought -- assuming you can live with my two helper columns in Sheet1. The first gives me a code to look up, the second simply duplicates the Activity # because lookups only look to the right and down (there are ways around this, but that adds even more complexity).

    If you can live with that (you can hide those columns, shown in green, if you like), then my solution is on Sheet2. You can change the course number and dates, and it will return the Activity # for up to 7 courses that meet those criteria, if any. If there are no matches, it shows up as a blank.
    Attached Files Attached Files

  25. #25
    Forum Contributor bentleybob's Avatar
    Join Date
    02-27-2009
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2010
    Posts
    644

    Re: HLookup

    Oops, sorry. One line got deleted in the previous file. Please use this one instead.
    Attached Files Attached Files

  26. #26
    Registered User
    Join Date
    04-14-2011
    Location
    Seattle, Washington
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: HLookup

    That looks amazing! So I can just transfer this over to the calendar format attached?
    Attached Files Attached Files

  27. #27
    Registered User
    Join Date
    04-14-2011
    Location
    Seattle, Washington
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: HLookup

    Also, is this something that will be easily to update? Once I learn about the formula I am sure I can play around with it a bit, where does the information in your "Lookup Code" column come from? I see it has multiple things in it at once..

  28. #28
    Forum Contributor bentleybob's Avatar
    Join Date
    02-27-2009
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2010
    Posts
    644

    Re: HLookup

    The lookup code is just data from Sheet1 -- Column B plus a "." and then the date (in number format), followed by a "-" and a number that increments for each occurrence of the same course code and date. The "." and "-" are just separators to make it easier to check the values. This then provides a unique reference for the lookups in Sheet2.

    This should be very easy to update assuming your basic formats don't change. Already, it's set up to look to entire columns, so you should be able to add data as needed and just copy the formulas down (make sure you copy ALL the formulas in the row).

    In Sheet2, you can copy any of the boxed-in areas AS A BLOCK down as far as you need, and the formulas will adapt. Please be aware that I formatted the cells in the row immediately below the dates using white font. That makes the formulas there work but they appear to b invisble. I did that only for aesthetic purposes. The formulas there tell the other cells in that column how many occurrences of that course and date there are so you get them all (or at least up to seven). If you ever need to go beyond seven, you will need to look at formulas in a few rows up to figure out how it works.

    If you ever decide to eliminate the "Course - " entry in Sheet 1 -- and just enter the course number -- that will require a number of changes, so maybe e-mail me if you need help on that. And let me know if you have other questions.

    Regards.
    bb

  29. #29
    Registered User
    Join Date
    04-14-2011
    Location
    Seattle, Washington
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: HLookup

    You are amazing. Thank you bob!

+ 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