# Vlookup and Match formula to look up name and a range of days.

I have a table, with names to the left and days on the top of the table, which are the amount of days a ticket is open in the system. I want a vlookup or any other that would work, to give me the number of tickets for 1 -2 days  3 -5 days 6 to 10 days and 11+ days for each name in the table. I have attached a sample sheet.samplesheet72215.xlsx
LVL 19
###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Finance AnalystCommented:
Formulas against first line C18 to F18:

=SUMIF(\$B\$1:\$M\$1,"<="&2,\$B2:\$M2)
=SUMIF(\$B\$1:\$M\$1,"<="&5,\$B2:\$M2)-SUM(\$C18:C18)
=SUMIF(\$B\$1:\$M\$1,"<="&10,\$B2:\$M2)-SUM(\$C18:D18)
=SUM(B2:M2)-SUM(C18:E18)

Copy down
Rob,

The data changes daily, can I use a named range so the totals change everyday?
Finance AnalystCommented:
Having another look but off for the night shortly.
Commented:
Another method is to have the min and max days in each group defined in cells, row 15 and 16 in the sheet.
In general I prefer to have limit values in cells, and not inside formulas.
The text in row 17 reflect the min and max numbers.
Then one formula in C18 can be copied to the entire range.
=SUMIFS(INDEX(\$B\$2:\$M\$11,MATCH(\$B18,\$A\$2:\$A\$11,0),0),\$B\$1:\$M\$1,">="&C\$15,\$B\$1:\$M\$1,"<="&C\$16)

Besides that the name range B18:B27 don't have to be in the same order as the data.

See sheet.
samplesheet72215.xlsx
That worked as well. Now how can I make a named range for this? My columns could be more or less on any given day and the data changes daily.
Commented:
DaysOpen, from B1 to the number of columns used.
NameList, from A2 to the number of rows used.
DataRange, from B2 to the number of rows in column A, and the number of columns in row 1.

You can add new rows with names and new columns for days open on the Data sheet.
The only requirement is that no empty cells are allowed in column A and row 1 in the lists.
The names on the Summary sheet are the NameList.
The Summary sheet is defined to row 20, copy if you need more.
samplesheet72215-ver-2.xlsx
I tried modifying this for my actual sheet and its not working. My data is actually in a pivot table. Does that change anything?
Commented:
Yes, that means it should probably be something else.

I guess it is possible to make a similar setup with reference to a pivot table, but why do that, when a pivot table is designated to make sums for categories.
I think it is much easier to make the classification in columns next to the pivot data with some simple formulas, and let the pivot table make the sum for each name.

Here is the same file I had before but I added a pivot the way it looks in my sheet. Row 4 on the sheet is the days open and the names are in column A.
samplesheet72215-ver-3.xlsx
Finance AnalystCommented:
on a spare sheet somewhere set up the following lookup table:

0      1-2 Days
3      3-5 Days
6      6-10 Days
11      11 or more days

I have put it in Summary K2:L5

Then in Sheet1, your pivot source data, include the following formula in column M with header "Group":

=VLOOKUP(L2,Summary!\$K\$2:\$L\$5,2)

Then in the pivot, expand the source data area to include column M and then drag "Group" as a column label instead of "Days Open".

Thanks
Rob H

Experts Exchange Solution brought to you by