array formula question

G

Gary Keramidas

i have an array formula that i'd like to evaluate in code and store it in a
variable instead of creating the array formula.

is it possible?

here is what the formula would look like if i wrote it to a cell:

range("A1").formulaarray = "=SUM(G" & iRow & ":I" & iRow &
")/TRANSPOSE($M$2:$M$4)*O" & iRow

i need to loop through some cells and total all of them, that's why i'd like to
store it in a variable.
 
D

Dave Peterson

Untested, uncompiled.

dim myVal as double
dim myFormula as string
dim iRow as long

for irow = 1 to 9
myformula = "SUM(G" & iRow & ":I" & iRow & ")/TRANSPOSE($M$2:$M$4)*O" & iRow
myval = activesheet.evaluate(myformula)
'do something with myval
next irow
 
G

Gary Keramidas

didn't seem to work, dave. i have some code that loops through the range and
gives me the result i need. i was wondering about a formula.

thanks
 
D

Dave Peterson

Does the formula work when you type it into a cell?

If yes, share that formula that worked.

Gary said:
didn't seem to work, dave. i have some code that loops through the range and
gives me the result i need. i was wondering about a formula.

thanks
 
G

Gary Keramidas

here's a similar formula that sort of works. i explain it in a separate post
because i was just looking for a formula, not a value to store in a variable.

=(SUM((1-TRANSPOSE(H2:H4))*G22:I22)+SUM(G22:I22))/TRANSPOSE($M$2:$M$4)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top