ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   using a formula in a program (https://www.excelbanter.com/excel-programming/404950-using-formula-program.html)

Ed[_30_]

using a formula in a program
 
I'm trying to write a program which will use the formula
("=SUMIF(AA8:AA208,3,C8:C208)" in a loop, except that I'd like to change the
integer "3" in the formula to a variable so that I can increase this value
each time through the loop.

The program works as long as I leave the value an integer "3". "4", etc. But
I can't make it work with a variable.

Can someone give me a boost that might help me with this problem?

Thanks



Rick Rothstein \(MVP - VB\)

using a formula in a program
 
Posting your code would have been helpful. Assuming your variable's name is
MyVar, I think this is what you are looking for..

MyVar = 4
<whatever you are assigning to = "=SUMIF(AA8:AA208," & MyVar & ",C8:C208"

Rick


"Ed" wrote in message
...
I'm trying to write a program which will use the formula
("=SUMIF(AA8:AA208,3,C8:C208)" in a loop, except that I'd like to change
the integer "3" in the formula to a variable so that I can increase this
value each time through the loop.

The program works as long as I leave the value an integer "3". "4", etc.
But I can't make it work with a variable.

Can someone give me a boost that might help me with this problem?

Thanks



Matthew Pfluger

using a formula in a program
 
Try this:

"=SUMIF(AA8:AA208," & variable & ",C8:C208)"

HTH,
Matthew Pfluger

"Ed" wrote:

I'm trying to write a program which will use the formula
("=SUMIF(AA8:AA208,3,C8:C208)" in a loop, except that I'd like to change the
integer "3" in the formula to a variable so that I can increase this value
each time through the loop.

The program works as long as I leave the value an integer "3". "4", etc. But
I can't make it work with a variable.

Can someone give me a boost that might help me with this problem?

Thanks




Ed[_30_]

using a formula in a program
 

Thanks very much Rick. I'll give it a try.


"Rick Rothstein (MVP - VB)" wrote in
message ...
Posting your code would have been helpful. Assuming your variable's name
is MyVar, I think this is what you are looking for..

MyVar = 4
<whatever you are assigning to = "=SUMIF(AA8:AA208," & MyVar & ",C8:C208"

Rick


"Ed" wrote in message
...
I'm trying to write a program which will use the formula
("=SUMIF(AA8:AA208,3,C8:C208)" in a loop, except that I'd like to change
the integer "3" in the formula to a variable so that I can increase this
value each time through the loop.

The program works as long as I leave the value an integer "3". "4", etc.
But I can't make it work with a variable.

Can someone give me a boost that might help me with this problem?

Thanks






All times are GMT +1. The time now is 05:25 PM.

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