![]() |
Creating a double lookup
I need some assistance on creating a "double lookup." Essentially what I am
trying to do is the following: Object: retrieve a number from multiple lists determined by company name and date. Source data would include a company name i.e. company A, B, or C and also the date an order was placed. Those two criteria would need to be used in order to determine the retrieved number. For example, if the order is for company B on 08/28/08. I would need to create a lookup that retrieves a number from list B for that date or later. Any help would be much appreciated. Thank you. |
Creating a double lookup
Here is something I put together if the company name is in A1:A23, the
date is in column B, and the number to retrieve is in column C Option Explicit Sub test() Dim cell As Range Dim Co As String Dim Dte As Date Co = InputBox("Company Name") Dte = InputBox("Date") For Each cell In Range("A1:A23") If cell.Value = Co Then If cell.Offset(0, 1).Value = Dte Then MsgBox cell.Offset(0, 2).Value End If End If Next cell End Sub |
Creating a double lookup
Still a little confused here. If anyone else could provide any additional
help, I would greatly appreciate it. Thanks. "GTVT06" wrote: Here is something I put together if the company name is in A1:A23, the date is in column B, and the number to retrieve is in column C Option Explicit Sub test() Dim cell As Range Dim Co As String Dim Dte As Date Co = InputBox("Company Name") Dte = InputBox("Date") For Each cell In Range("A1:A23") If cell.Value = Co Then If cell.Offset(0, 1).Value = Dte Then MsgBox cell.Offset(0, 2).Value End If End If Next cell End Sub |
Creating a double lookup
Maybe this:
http://www.contextures.com/xlFunctio...ml#IndexMatch2 The MATCH function can be used to return values for both the row_num and column_num arguments in the INDEX function. Regards, Ryan--- -- RyGuy "Kenton" wrote: Still a little confused here. If anyone else could provide any additional help, I would greatly appreciate it. Thanks. "GTVT06" wrote: Here is something I put together if the company name is in A1:A23, the date is in column B, and the number to retrieve is in column C Option Explicit Sub test() Dim cell As Range Dim Co As String Dim Dte As Date Co = InputBox("Company Name") Dte = InputBox("Date") For Each cell In Range("A1:A23") If cell.Value = Co Then If cell.Offset(0, 1).Value = Dte Then MsgBox cell.Offset(0, 2).Value End If End If Next cell End Sub |
Creating a double lookup
Thank you. Thank you. I had to enter some additional information, i.e. fill
in all the dates as I was not doing a lookup but with that one small exception this works perfectly. Thanks again. "ryguy7272" wrote: Maybe this: http://www.contextures.com/xlFunctio...ml#IndexMatch2 The MATCH function can be used to return values for both the row_num and column_num arguments in the INDEX function. Regards, Ryan--- -- RyGuy "Kenton" wrote: Still a little confused here. If anyone else could provide any additional help, I would greatly appreciate it. Thanks. "GTVT06" wrote: Here is something I put together if the company name is in A1:A23, the date is in column B, and the number to retrieve is in column C Option Explicit Sub test() Dim cell As Range Dim Co As String Dim Dte As Date Co = InputBox("Company Name") Dte = InputBox("Date") For Each cell In Range("A1:A23") If cell.Value = Co Then If cell.Offset(0, 1).Value = Dte Then MsgBox cell.Offset(0, 2).Value End If End If Next cell End Sub |
All times are GMT +1. The time now is 09:35 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com