I want to create the IF formula in column C within VBA. However, when I do it, the formula comes out as using values of the cells rather than the cell reference. I want to know how to use cell reference:
[Have the formula say [=IF(B2>0,2,A2)]
rather than [=IF(1>0,2,1]
in my excel sheet for cell C2 when the VBA is ran.]
Dim c As Range
Dim a As Integer
Dim b As Integer
'//loop it in column C
For Each c In Range(Range("C2"), Range("C2").End(xlDown))
a = c.Offset(0, -1) '// Column B
b = c.Offset(0, -2) '// Column A
c.Formula = "=IF(" & b & ">0,2," & a & ")" '// same format as formula [=IF(B2>0,2,A2)]
Next