Entering formulas via VBA

R

Ron

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
 
N

Niek Otten

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

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