ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Calculate the result of an array in vba (https://www.excelbanter.com/excel-programming/415513-calculate-result-array-vba.html)

Sam

Calculate the result of an array in vba
 
For Each c In Range("A2", Range("A2").End(xlDown))
I would like vba to enter the result of the following array formula into
column P in each row:

{=SUM((A$2:A$1000=A2)*(F$2:F$1000=F2)*G$2:G$1000)}

I would like to do this without actually entering the formula -- only the
value.

Any help would be appreciated.

Thanks,

Sam



Dave Peterson

Calculate the result of an array in vba
 
I'd add the formulas and then convert them to values.

If you blink, you may not even notice the formulas!

Option Explicit
Sub testme()

Dim myRng As Range
With ActiveSheet
Set myRng = .Range("p2:p" & .Range("a2").End(xlDown).Row)
End With

With myRng
.Formula = "=SUMproduct((A$2:A$1000=A2)*(F$2:F$1000=F2)*G$2:G $1000)"
.Value = .Value
End With
End Sub



Sam wrote:

For Each c In Range("A2", Range("A2").End(xlDown))
I would like vba to enter the result of the following array formula into
column P in each row:

{=SUM((A$2:A$1000=A2)*(F$2:F$1000=F2)*G$2:G$1000)}

I would like to do this without actually entering the formula -- only the
value.

Any help would be appreciated.

Thanks,

Sam


--

Dave Peterson


All times are GMT +1. The time now is 06:54 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com