Shan
Shan

Reputation: 439

VBA IF function error

I want to insert the following formula to a cell

Range("Q12").FormulaR1C1 = "=If(P12>1,1,P12)"

but my output in the cell is below

=WENN('P12'>1;1;'P12')

the problem is it includes ' ' . Please help me to correct this problem

Thanks

Upvotes: 0

Views: 57

Answers (1)

Gary's Student
Gary's Student

Reputation: 96753

Use the non-R1C1 format:

Sub hfdjs()
    Range("Q12").Formula = "=If(P12>1,1,P12)"
End Sub

Upvotes: 2

Related Questions