# Dynamic Array Formula

#### flexinau

##### Board Regular
Is it possible to have a dynamic range formula where you are using an array

i.e. sum(if(A2:A10000="Condition",B2:B10000,""))

When I say dynamic, sometimes instead of looking at row 2 to 10000, I may only want to look at say 2 to 500 rows.

Then more rows you use on an array, the slower Excel is.

The smaller the number of rows, the quicker Excel's processing time.

Thanks

### Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

#### acw

##### MrExcel MVP
Hi

one way is to build a dynamic named range that can be used in the formula

insert, name, define, yourname1, refers to:=offset(sheet1!\$a\$2,0,0,counta(\$a:\$a),1)
insert, name, define, yourname2, refers to:=offset(yourname1,0,1)

the formula is then
=sum(if(yourname1="Condition",yourname2,0))

Tony

#### flexinau

##### Board Regular
Tony,
Would this formula work on a CSE formula too like my example above?

#### acw

##### MrExcel MVP
If by CSE you mean array entered, then yes.

Tony

##### MrExcel MVP
flexinau said:
Is it possible to have a dynamic range formula where you are using an array

i.e. sum(if(A2:A10000="Condition",B2:B10000,""))

When I say dynamic, sometimes instead of looking at row 2 to 10000, I may only want to look at say 2 to 500 rows.

Then more rows you use on an array, the slower Excel is.

The smaller the number of rows, the quicker Excel's processing time.

Thanks

Just to make sure: the formula you posted can be replaced with an ordinary SumIf formula.

1. If you can specify or compute the To of From:To, you can use idiom like:

{=SUM(IF(\$A\$2:INDEX(A:A,To)="X",IF(\$B\$2:INDEX(B:B,To)=1,\$C\$2:INDEX(C:C,To))))}

2. If you want to feed the formula the actual size of data which expands/crimps, you might want to opt for creating the so-called dynamic named ranges. For example:

Name: Arange

Definition:

=Sheet1!\$A\$2:INDEX(Sheet1!\$A:\$A,Lrec)

Name: Brange

Definition:

=Sheet1!\$B\$2:INDEX(Sheet1!\$B:\$B,Lrec)

Name: Crange

Definition:

=Sheet1!\$C\$2:INDEX(Sheet1!\$C:\$C,Lrec)

where Lrec is defined, based on column C with numeric data, as:

=MATCH(9.99999999999999E+307,Sheet1!\$C:\$C)-ROW(Sheet1!\$C\$2)+1

Be aware that such dynamic named ranges are also resource-intensive.

The preceeding formula becomes:

{=SUM(IF(Arange="X",IF(Brange=1,Crange)))}

3. If you are on Excel 2003, convert the data range of interest into a list by means of Data|List|Create List.

The 3rd option is the best.

Replies
3
Views
192
Replies
5
Views
323
Replies
8
Views
296
Replies
3
Views
330
Replies
2
Views
552

1,195,961
Messages
6,012,582
Members
441,713
Latest member
Dave353

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