I am using VBA to put a formula into a cell.
The formula I want to put is based on a counter, i.
The desired formula would be: =IF($B384 > 0, $H384, "") where the row number is derived by a counter.
My code is:
Lastentry = Lastentry - 1
For i = Lastentry To Lastentry + Addrow
Worksheets(2).Cells(Lastentry, "I") = "=" & "B" & Lastentry & " * " & "G" & Lastentry
Worksheets(2).Cells(Lastentry, "O") = "=" & "$B" & Lastentry & " * " & "$F" & Lastentry
Worksheets(2).Cells(Lastentry, "P") = "=IF($B" & Lastentry & " > " & 0 & ", $H" & Lastentry & ","")"
Lastentry = Lastentry + 1
Next i
However, the formula never comes out right. the last "" between the comma and the right bracket never comes out properly.
The result I get is: =IF($B389 > 0, $H389,")
What can I do?
The formula I want to put is based on a counter, i.
The desired formula would be: =IF($B384 > 0, $H384, "") where the row number is derived by a counter.
My code is:
Lastentry = Lastentry - 1
For i = Lastentry To Lastentry + Addrow
Worksheets(2).Cells(Lastentry, "I") = "=" & "B" & Lastentry & " * " & "G" & Lastentry
Worksheets(2).Cells(Lastentry, "O") = "=" & "$B" & Lastentry & " * " & "$F" & Lastentry
Worksheets(2).Cells(Lastentry, "P") = "=IF($B" & Lastentry & " > " & 0 & ", $H" & Lastentry & ","")"
Lastentry = Lastentry + 1
Next i
However, the formula never comes out right. the last "" between the comma and the right bracket never comes out properly.
The result I get is: =IF($B389 > 0, $H389,")
What can I do?