ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   using code variable to write cell formula (https://www.excelbanter.com/excel-programming/366328-using-code-variable-write-cell-formula.html)

RPW

using code variable to write cell formula
 
Hi all,

The following gets a compile error expected:end of statement and the second
set of quotation marks are highligted.

uf = cellb.Row
Worksheets("Basic Pricing").Range("F202").Formula =
"=if(d2020,lookup(d202,'Materials & Multipliers'!$d5:$d"& uf & ",'Materials
& Multipliers'!$e5:$e"& uf & "),0)"

I've tried building the string step by step with (a variable uf) but the
cell formula doesn't update.

Worksheets("Basic Pricing").Range("F202").Formula = uf

Help with either or both would be much appreciated.

--
rpw

Charlie

using code variable to write cell formula
 
"=if(d2020,lookup(d202,'Materials & Multipliers'!$d5:$d" & uf & ",'Materials
& Multipliers'!$e5:$e" & uf & "),0)"

need a space between the " and the &

"rpw" wrote:

Hi all,

The following gets a compile error expected:end of statement and the second
set of quotation marks are highligted.

uf = cellb.Row
Worksheets("Basic Pricing").Range("F202").Formula =
"=if(d2020,lookup(d202,'Materials & Multipliers'!$d5:$d"& uf & ",'Materials
& Multipliers'!$e5:$e"& uf & "),0)"

I've tried building the string step by step with (a variable uf) but the
cell formula doesn't update.

Worksheets("Basic Pricing").Range("F202").Formula = uf

Help with either or both would be much appreciated.

--
rpw


RPW

using code variable to write cell formula
 
Thanks Charlie!

And also between the uf and the &.
--
rpw


"Charlie" wrote:

"=if(d2020,lookup(d202,'Materials & Multipliers'!$d5:$d" & uf & ",'Materials
& Multipliers'!$e5:$e" & uf & "),0)"

need a space between the " and the &

"rpw" wrote:

Hi all,

The following gets a compile error expected:end of statement and the second
set of quotation marks are highligted.

uf = cellb.Row
Worksheets("Basic Pricing").Range("F202").Formula =
"=if(d2020,lookup(d202,'Materials & Multipliers'!$d5:$d"& uf & ",'Materials
& Multipliers'!$e5:$e"& uf & "),0)"

I've tried building the string step by step with (a variable uf) but the
cell formula doesn't update.

Worksheets("Basic Pricing").Range("F202").Formula = uf

Help with either or both would be much appreciated.

--
rpw



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

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