LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 13
Default Help with parameter substitution in formula (&value), vbScript

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.
 
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
variable substitution in a formula linking to external workbook my Excel Discussion (Misc queries) 2 August 29th 07 03:05 PM
variable substitution in a formula NHRunner Excel Discussion (Misc queries) 5 May 11th 07 01:56 PM
Parameter Query Cell substitution Jockel Excel Discussion (Misc queries) 2 December 8th 06 04:28 PM
Cell Formula substitution. id3372 Excel Discussion (Misc queries) 3 July 8th 06 04:36 PM
why does ON = Ambiguous in substitution formula? waladd Excel Worksheet Functions 5 May 6th 05 05:29 PM


All times are GMT +1. The time now is 09:35 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"