Thread: Lookup Values
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Harlan Grove[_2_] Harlan Grove[_2_] is offline
external usenet poster
 
Posts: 1,231
Default Lookup Values

Harlan wrote...
....
. . . I use the account numbers as the lookup value. *The table is then
one of the sheets in the workbook, named for the year (2009, 2010, etc.). *
Now here's where it gets tricky. I have to other values. *The first is the
accounting period number, which is what I have been using in the past. *Those
13 numbers are the first row across the top. *The second number is going to
be the week in the period (1, 2, 3, or 4) . *So I want to look for a value in
the 2009 sheet, for period 9, week 2. *How would I go about doing this? *Is
it even possible? *For reference, here is the formula that I have been using

VLOOKUP(A10,INDIRECT("'"&$P$3&"'!$A$1:$P$165"),
MATCH($P$4,INDIRECT("'"&$P$3&"'!$A$1:$O$1"),0),FA LSE)

Where $P$3 is the year and $P$4 is the period. *
$A$1:$P$165 is the table with all the values.
$A$1:$O$1 is the first row of the worksheet with the numbers 1-13. *

....

Looks like there could be a mistake in the 2nd argument to the MATCH
call. If A10 is an account number, that account number would be sought
in col A of the A1:P165 range, but you're also looking up the P4 value
in A1:O1. Do the rows 1 in the other worksheets contain column
headings? If so, the lookup table should be A2:P165.

That said, you haven't provided enough information. You mentioned that
Period was in row 1 in the year worksheets, but where is week? 4
weekly columns per period? Weeks in different rows?

If there were 4 columns for weeks within each period, so the table
contained at least 53 columns (1st col for account numbers/IDs, next 4
cols for weeks 1 to 4 in period 1, next 4 cols for weeks 1 to 4 in
period 2, etc.), then your formula could be simplified to

=VLOOKUP(A10,CHOOSE(MATCH($P$3,{2009;2010;2011;... }),
'2009'!$B$2:$BA$165,'2010'!$B$2:$BA$165,'2010'!$B$ 2:$BA$165,...),
4*(PeriodNumber-1)+WeekNumber,0)

Maybe the CHOOSE(MATCH(...),...) isn't a simplification, but it avoids
volatile INDIRECT calls. Since you're using relative and absolute
references, it looks like there may be a lot of these formulas. A lot
of formulas each calling volatile functions can really slow down
recalculation.