# VBA Function query

#### KeelySG

##### New Member
Hi folks

I'm trying to create a VBA function which generates quite a complex formula if there's a particular value in Cell G25. Can anyone help please?

My formula is:
=IF(G25="46mm",INDEX(Matrix!A:K,AGGREGATE(15,3,((Matrix!\$B\$6:\$B\$13>=M25)/(Matrix!\$B\$6:\$B\$13>=M25))*ROW(Matrix!\$B\$6:\$B\$13),1),AGGREGATE(15,3,((Matrix!\$C\$5:\$G\$5>=I25)/(Matrix!\$C\$5:\$G\$5>=I25))*COLUMN(Matrix!\$C\$5:\$G\$5),1)),IF(G25="67mm",INDEX(Matrix!A:K,AGGREGATE(15,3,((Matrix!\$B\$6:\$B\$13>=M25)/(Matrix!\$B\$6:\$B\$13>=M25))*ROW(Matrix!\$B\$6:\$B\$13),1),AGGREGATE(15,3,((Matrix!\$C\$5:\$K\$5>=I25)/(Matrix!\$C\$5:\$K\$5>=I25))*COLUMN(Matrix!\$C\$5:\$K\$5),1)),IF(G25="90mm",INDEX(Matrix!A:K,AGGREGATE(15,3,((Matrix!\$B\$6:\$B\$13>=M25)/(Matrix!\$B\$6:\$B\$13>=M25))*ROW(Matrix!\$B\$6:\$B\$13),1),AGGREGATE(15,3,((Matrix!\$C\$5:\$G\$5>=I25)/(Matrix!\$C\$5:\$G\$5>=I25))*COLUMN(Matrix!\$C\$5:\$G\$5),1)))))+AL25

I'm currently using the above formula in Cell AG25 but it's generating a #VALUE! error where there's no content in cell G25.

### Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

#### bobsan42

##### Well-known Member
What is in AL25 ?
What is the result if you remove +AL25 ?
And what is the result if you put +AL25 inside the IF brackets? (move the last bracket after AL25)

#### KeelySG

##### New Member
In this cell there's a formula which is dependent on others in the row, that returns another value (currency). If I put this inside the brackets, it doesn't return a value.

Replies
3
Views
22
Replies
1
Views
34
Replies
6
Views
75
Replies
2
Views
54
Replies
5
Views
40