# Dynamic Excel Range question

#### yodachoda

##### New Member
Hi all,

So let's say my data looks like this:

Date

6/1/2015
6/1/2015
6/1/2015
6/1/2015
6/2/2015
6/2/2015
6/3/2015
6/3/2015
6/3/2015
6/3/2015
6/3/2015
6/3/2015
6/4/2015
6/4/2015

Where the top date is in cell A2 and the last date is in cell A15, in a sheet called "Written".

In a separate sheet within the workbook, I'd like to use a countifs formula for each date, but within the formula rather than defining the range as "Written!A2:A15" I'd like to define it as the starting row for a date to the ending row for a date. So for a countifs for 6/3/2015, I'd like the range to be defined as A7:A12. The reason is I am thinking this will speed up a slow workbook that has many countifs formulas. It's unusable now but I am hoping this will make it fast.

Now it gets a little trickier than that. Rather than manually type or select A7-A12, I'd like for when I drag down the countifs formula (to match descending dates: 6/3/2015 in the top cell, 6/4/2015 in the cell right below, ect), it automatically changes the range to include only the data set for the specific date.

I already have a formula that will give the row # that each date starts and stops at: =MATCH(6/3/2015, Written!A2:A15, 0) gives a result of 7 and =MATCH(6/3/2015+1, Written!A2:A15, 0)-1 gives a result of 12.

I just need for the numbers in the countifs formula range of A7:A12 to link to these match formulas rather than the "normal" way of linking to the Written tab's raw data.

This might seem like alot to do for no purpose but again, with many many countifs formulas and some array formulas, if they each are searching through an entire range, it seems like this is likely the cause of my slowdowns and using limited, automatically shifting ranges will help. Thanks.

### Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Maybe use SUMPRODUCT.
Excel Workbook
ABCDEFG
1DateDateCountCount of "a"
26/1/2015a6/1/201543
36/1/2015b6/2/201521
46/1/2015a6/3/201565
56/1/2015a6/4/201521
66/2/2015a
76/2/2015b
86/3/2015a
96/3/2015a
106/3/2015a
116/3/2015b
126/3/2015a
136/3/2015a
146/4/2015a
156/4/2015b
16
Sheet

@AhoyNC

SUMPRODUCT will be less efficient than COUNTIFS.

Replies
1
Views
252
Replies
0
Views
185
Replies
5
Views
523
Replies
3
Views
258
Replies
3
Views
236

1,196,274
Messages
6,014,394
Members
441,818
Latest member
itsfaisalkhalid

### 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.

### Which adblocker are you using?

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

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