ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Variable used in a =SUMIF() function? (https://www.excelbanter.com/excel-worksheet-functions/242279-variable-used-%3Dsumif-function.html)

circuit_breaker

Variable used in a =SUMIF() function?
 
Hi,

How do I replace the "A40" parameter with the nLastrow varable below?

nLastrow = 100

objExcel.ActiveSheet.Range("D20").Formula = "=SUMIF
(A4:A40,""'5734' "",B4:B40)"

I've been trying many things with double-double quotes but nothing
works.

Thanks.

circuit_breaker

Variable used in a =SUMIF() function?
 
On Sep 10, 1:30*pm, circuit_breaker
wrote:
Hi,

How do I replace the "A40" parameter with the nLastrow varable below?

* nLastrow = 100

* objExcel.ActiveSheet.Range("D20").Formula = "=SUMIF
* (A4:A40,""'5734' "",B4:B40)"

I've been trying many things with double-double quotes but nothing
works.

Thanks.


This worked:

ActiveSheet.Range("D20").formula="=SUMIF(A4:A"&nRo w
&",""'5734'"",B4:B41)"

Bob Phillips[_3_]

Variable used in a =SUMIF() function?
 
objExcel.ActiveSheet.Range("D20").Formula = _
"=SUMIF(A4:A" & nLastRow & ",""'5734' "",B4:B" & nLastRow & ")"


--
__________________________________
HTH

Bob

"circuit_breaker" wrote in message
...
Hi,

How do I replace the "A40" parameter with the nLastrow varable below?

nLastrow = 100

objExcel.ActiveSheet.Range("D20").Formula = "=SUMIF
(A4:A40,""'5734' "",B4:B40)"

I've been trying many things with double-double quotes but nothing
works.

Thanks.




Dave Peterson

Variable used in a =SUMIF() function?
 
I'm not sure what you're doing, but even though excel is forgiving, I'd want my
ranges to be the same size. And are you sure you want those single quotes
around that 5734?

Just in case you want to try it:

ActiveSheet.Range("D20").Formula _
= "=SUMIF(A4:A" & nRow & ",""5734"",B4:B" & nRow & ")"

circuit_breaker wrote:

On Sep 10, 1:30 pm, circuit_breaker
wrote:
Hi,

How do I replace the "A40" parameter with the nLastrow varable below?

nLastrow = 100

objExcel.ActiveSheet.Range("D20").Formula = "=SUMIF
(A4:A40,""'5734' "",B4:B40)"

I've been trying many things with double-double quotes but nothing
works.

Thanks.


This worked:

ActiveSheet.Range("D20").formula="=SUMIF(A4:A"&nRo w
&",""'5734'"",B4:B41)"


--

Dave Peterson


All times are GMT +1. The time now is 09:53 AM.

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