ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Entering formulas via VBA (https://www.excelbanter.com/excel-programming/346416-entering-formulas-via-vba.html)

Ron[_32_]

Entering formulas via VBA
 
Hi all,

Can anyone help me with a workaround for this line of code?

Range("r2").Formula = "=IF(Q2="w",(P2*(E2-1)*0.95),-P2)"

When the compiler gets to the "w" part of the formula it's expecting "w" to
be a variable or something as it sees me as closing this part "=IF(Q2="

I'm sure there's a simple explanation that I'm overlooking?

Any help or pointers appreciated

Ron

Niek Otten

Entering formulas via VBA
 
For quotes within quotes, use two quotes
Range("r2").Formula = "=IF(Q2=""w"",(P2*(E2-1)*0.95),-P2)"

--
Kind regards,

Niek Otten



"Ron" wrote in message
...
Hi all,

Can anyone help me with a workaround for this line of code?

Range("r2").Formula = "=IF(Q2="w",(P2*(E2-1)*0.95),-P2)"

When the compiler gets to the "w" part of the formula it's expecting "w"
to
be a variable or something as it sees me as closing this part "=IF(Q2="

I'm sure there's a simple explanation that I'm overlooking?

Any help or pointers appreciated

Ron




Ron[_32_]

Entering formulas via VBA
 
Niek,

Ecellent, thankyou very much.

Ron











"Niek Otten" wrote in news:#T$uQhD8FHA.2816
@tk2msftngp13.phx.gbl:

For quotes within quotes, use two quotes
Range("r2").Formula = "=IF(Q2=""w"",(P2*(E2-1)*0.95),-P2)"




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

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