VBA Array formula

ziad alsayed

Well-known Member
Joined
Jul 17, 2010
Messages
665
dear all

this is an array formula,i press ( CTRL+SHIFT+ENTER) for it to work in excel

how can i write it in VBA?

Code:
=SUM(VLOOKUP(RC1,'PHC 2011'!C1:C86,MATCH(CONCATENATE(R1C1,R4C),CONCATENATE('PHC 2011'!R4,'PHC 2011'!R5),0),0),VLOOKUP(RC1,'Apapa 2011'!C1:C86,MATCH(CONCATENATE(R1C1,R4C),CONCATENATE('Apapa 2011'!R4,'Apapa 2011'!R5),0),0),VLOOKUP(RC1,'VI 2011'!C1:C86,MATCH(CONCATENATE(R1C1,R4C),CONCATENATE('VI 2011'!R4,'VI 2011'!R5),0),0),VLOOKUP(RC1,'Kano 2011'!C1:C86,MATCH(CONCATENATE(R1C1,R4C),CONCATENATE('Kano 2011'!R4,'Kano 2011'!R5),0),0),VLOOKUP(RC1,'Ikeja 2011'!C1:C86,MATCH(CONCATENATE(R1C1,R4C),CONCATENATE('Ikeja 2011'!R4,'Ikeja 2011'!R5),0),0))

let say i want to put in cells(5,3).

appreciate any help
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Just use FormulaArray. A sinple example to invert the matrix in D4:F6 puting result at A1:C3

Range("A1:C3").FormulaArray = "=MINVERSE("D4:F6")"
 
Upvote 0
Sorry, I made a mistake. This is the correct formula>

Range("A1:C3").FormulaArray = "=MINVERSE(D4:F6)"

In Sheet1 type (for instance):

1 2 3
4 5 5
7 7 7

in range D4:F6. One number per cell.

In VBA create a Module and type

Public Sub Inversion()
Range("A1:C3").FormulaArray = "=MINVERSE(D4:F6)"
End Sub

Running the macro you'll get your CTRL+SHIFT+ENTER
You can try TRANSPOSE, MMULT, etc.
 
Upvote 0
i tried the example, an it works, but this is not what i need

the result of my formula is only in one cell.
simple what it does , os that it sum cells from many sheets.

any other idea??

thanks for your help.
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,282
Members
452,902
Latest member
Knuddeluff

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