Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default array formula question

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


Gary



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default array formula question

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



Gary Keramidas wrote:

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

Gary


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default array formula question

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

--


Gary


"Dave Peterson" wrote in message
...
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



Gary Keramidas wrote:

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

Gary


--

Dave Peterson



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default array formula question

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

If yes, share that formula that worked.

Gary Keramidas wrote:

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

--

Gary

"Dave Peterson" wrote in message
...
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



Gary Keramidas wrote:

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

Gary


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default array formula question

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)

--


Gary


"Dave Peterson" wrote in message
...
Does the formula work when you type it into a cell?

If yes, share that formula that worked.

Gary Keramidas wrote:

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

--

Gary

"Dave Peterson" wrote in message
...
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



Gary Keramidas wrote:

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

Gary

--

Dave Peterson


--

Dave Peterson



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Array Formula Question IPerlovsky Excel Worksheet Functions 6 March 10th 07 05:04 AM
Formula/Array question with dates Renee Excel Worksheet Functions 1 November 24th 05 01:52 AM
Array Formula question nicgendron[_10_] Excel Programming 2 August 19th 05 03:15 PM
SUM array formula question Dan Excel Worksheet Functions 6 November 8th 04 05:49 AM
Array Formula Question Don Wiss Excel Programming 1 December 19th 03 05:09 AM


All times are GMT +1. The time now is 04:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"