You don't need a loop
You can work with a single shot range in colunm G that
- Adds a formula from G5 to the user entered
iRowNumber
to test whether a result > 0 happens in each row (or adds""
for a 0 result) overwrite the formulae with the values
Sub calcprice() Dim iRowNumber As Long ' Integer to store result in iRowNumber = InputBox(Prompt:="Number of Rows", _ Title:="Rows: ", Default:="# of Rows") With Range(Cells(5, 7), Cells(iRowNumber, 7)) .FormulaR1C1 = "=IF(N(RC[-1]*RC[-2]),RC[-1]*RC[-2],"""")" .Value = .Value End With End Sub