dynamic named range based on range of dates

kcmuppet

Active Member
Joined
Nov 2, 2005
Messages
439
Office Version
  1. 365
Platform
  1. Windows
Hi,

I would like use a dynamic named range as a pivot table source with but pull only rows within a date range, specified in two cells outside the table

The full range is:
=OFFSET(Expenses!$B$2,0,0,COUNTA(Expenses!$B:$B),16)

...where col B contains dates

I'm thinking it probably needs to be using INDEX & MATCH, but I keep getting stuck on how to specify a range between two dates, instead of just matching a specific date.

Could somebody point me in the direction please?

Thanks very much.
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Here's as far as I've got:

=Expenses!$B$2:INDEX(Expenses!$B$2:$R$10000,MATCH(TRUE,INDEX(AND(Expenses!$B$2:$B$10000<=sheet1!B7,Expenses!$B$2:$B$10000>=sheet1!b8)),FALSE)),0)

What appreciate some help understanding where I'm going wrong. Is it the use of the AND function?

Thanks
 
Upvote 0
Here's as far as I've got:

=Expenses!$B$2:INDEX(Expenses!$B$2:$R$10000,MATCH(TRUE,INDEX(AND(Expenses!$B$2:$B$10000<=sheet1!B7,Expenses!$B$2:$B$10000>=sheet1!b8)),FALSE)),0)

What appreciate some help understanding where I'm going wrong. Is it the use of the AND function?

Thanks

Define Lrec as referring to:

=MATCH(9.99999999999999E+307,Expenses!$B:$B)

Define DateRange as referring to:

=Expenses!$B$2:INDEX(Expenses!$B:$B,Lrec)

Define LBound as referring to:

=Sheet1!$B$7

Define UBound as referring to:

=Sheet1!$B$8

Define CondLrec as referring to:

=MATCH(1,IF(DateRange>=LBound,IF(DateRange<=Ubound,1)),0)

Define DATA as referring to:

=Expenses!$B$2:INDEX(Expenses!$R:$R,CondLrec)
 
Upvote 0
Hi Aladin,

Thanks for your response.

It's an ingenious looking solution (not sure I understand it all), but unfortunately

=MATCH(9.99999999999999E+307,Expenses!$B:$B) produces "Reference not Valid" for me.

Is the idea that this will find the last cell date, in the range?

Would an offset be a better way to do this bit?
 
Upvote 0
Here's as far as I've got:

=Expenses!$B$2:INDEX(Expenses!$B$2:$R$10000,MATCH(TRUE,INDEX(AND(Expenses!$B$2:$B$10000<=sheet1!B7,Expenses!$B$2:$B$10000>=sheet1!b8)),FALSE)),0)

What appreciate some help understanding where I'm going wrong. Is it the use of the AND function?

Thanks
Try this...

Sheet2 A1 = lower date boundary
Sheet2 B1 = upper date boundary

=INDEX(Expenses!$B:$Q,MATCH(Sheet2!$A$1,Expenses!$B:$B,0),0):INDEX(Expenses!$B:$Q,MATCH(Sheet2!$B$1,Expenses!$B:$B,0),0)
 
Upvote 0
Try this...

Sheet2 A1 = lower date boundary
Sheet2 B1 = upper date boundary

=INDEX(Expenses!$B:$Q,MATCH(Sheet2!$A$1,Expenses!$B:$B,0),0):INDEX(Expenses!$B:$Q,MATCH(Sheet2!$B$1,Expenses!$B:$B,0),0)

Hi T,

That produces reference not valid for me. Do the dates have to be in order for that to work?

Perhaps I should explain a bit more about the data in Expenses!$B:$B? The table header is in Row 2, then a couple of thousand rows of dates, then variable gap of 20-30 rows, then a line of text
 
Upvote 0
Hi T,

That produces reference not valid for me. Do the dates have to be in order for that to work?

Perhaps I should explain a bit more about the data in Expenses!$B:$B? The table header is in Row 2, then a couple of thousand rows of dates, then variable gap of 20-30 rows, then a line of text
No, the dates do not have to be sorted.

It works for me as a general use dynamic range but I didn't try to use it as the source for a pivot table.

Sorry, I don't have any other suggestions.
 
Upvote 0
Hi Aladin,

Thanks for your response.

It's an ingenious looking solution (not sure I understand it all), but unfortunately

=MATCH(9.99999999999999E+307,Expenses!$B:$B) produces "Reference not Valid" for me.

Is the idea that this will find the last cell date, in the range?

Would an offset be a better way to do this bit?

Yes, that formula is supposed to yield the row number of the last date value in column B on Expenses.
 
Upvote 0

Forum statistics

Threads
1,224,566
Messages
6,179,558
Members
452,928
Latest member
101blockchains

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top