Help with parameter substitution in formula (&value), vbScript

C

circuit_breaker

Hi,

I want to replace the "A40" parameter in the below formula with a
variable because this parameter should be dynamic. In short, I want
to replace the "A40" nLastRow variable. "I'm using vbScript and not
Excel's VBA. Here's the code I use:

nLastrow = objExcel.ActiveSheet.Range("B4").End(-4121).Row
objExcel.ActiveSheet.Range("D20").Formula = "=SUMIF
(A4:A40,"">'5734'"",B4:B40)" ' This works.

'This fails: objExcel.ActiveSheet.Range("D"").Formula = "=SUMIF
(A4:A&nLastRow,"">'5734'"",B4:B40)" ' This works.

Thanks for your help.
 

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