ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Problem writing formula (https://www.excelbanter.com/excel-programming/366360-problem-writing-formula.html)

Alf[_13_]

Problem writing formula
 

I'm trying to write a formula with VB but having problems.

Cell "C3" cotains a number (12,45) so I want to construct the formula
"=B12" in cell "K10".

Range("K10").Formula = "= b & Int(C3)"
This gives me a #NAME? error in K10.

Range("K10").Formula = "= "b" & Int(C3)"
VB says "Compile error Expected: End of Statement

Range("K10").Formula = "= ""b"" & Int(C3)"
This gives me the string value "b12" in "K12"

Could somebody please help me with the propper syntax for writing the
formula "=b12" in "K10".


--
Alf
------------------------------------------------------------------------
Alf's Profile: http://www.excelforum.com/member.php...fo&userid=7112
View this thread: http://www.excelforum.com/showthread...hreadid=558661


Trevor Shuttleworth

Problem writing formula
 
Alf

Try:

Range("K10").Formula = "=B" & Int(Range("C3"))

Regards

Trevor


"Alf" wrote in message
...

I'm trying to write a formula with VB but having problems.

Cell "C3" cotains a number (12,45) so I want to construct the formula
"=B12" in cell "K10".

Range("K10").Formula = "= b & Int(C3)"
This gives me a #NAME? error in K10.

Range("K10").Formula = "= "b" & Int(C3)"
VB says "Compile error Expected: End of Statement

Range("K10").Formula = "= ""b"" & Int(C3)"
This gives me the string value "b12" in "K12"

Could somebody please help me with the propper syntax for writing the
formula "=b12" in "K10".


--
Alf
------------------------------------------------------------------------
Alf's Profile:
http://www.excelforum.com/member.php...fo&userid=7112
View this thread: http://www.excelforum.com/showthread...hreadid=558661




Alf[_14_]

Problem writing formula
 

Thanks Trevor

Worked perfecly!!!!


--
Alf
------------------------------------------------------------------------
Alf's Profile: http://www.excelforum.com/member.php...fo&userid=7112
View this thread: http://www.excelforum.com/showthread...hreadid=558661


Trevor Shuttleworth

Problem writing formula
 
You're welcome ... thanks for the feedback


"Alf" wrote in message
...

Thanks Trevor

Worked perfecly!!!!


--
Alf
------------------------------------------------------------------------
Alf's Profile:
http://www.excelforum.com/member.php...fo&userid=7112
View this thread: http://www.excelforum.com/showthread...hreadid=558661





All times are GMT +1. The time now is 01:43 AM.

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