计算公式循环VBA的结果

计算公式循环VBA的结果,vba,math,excel-formula,Vba,Math,Excel Formula,我正在尝试使用此代码计算公式的结果,但由于某些原因,我无法理解为什么它不在循环中打印 Sub findx() Dim A, B, fct As Variant Dim k, i As Long fct = InputBox("What is the function in terms of x?") A = InputBox("Set lower boundary") B = InputBox("Set upper boundary") i = InputBox("How many times

我正在尝试使用此代码计算公式的结果,但由于某些原因,我无法理解为什么它不在循环中打印

Sub findx()
Dim A, B, fct As Variant
Dim k, i As Long

fct = InputBox("What is the function in terms of x?")
A = InputBox("Set lower boundary")
B = InputBox("Set upper boundary")
i = InputBox("How many times would you like to repeat this algorithm?")


Range("A6").Value = A
Range("B6").Value = B

For k = i To k = i + 6

Cells(k, 5).Value = "=" & Replace(LCase(fct), "x", Cells(k, 1).Value)
k = k + 1
Next


End Sub

移除
k=k+1
-您的For循环已经处理了这个
单元格(k,5)。公式=“=”&Replace(LCase(fct),“x”,单元格(k,1)。Value)
它不只是
单元格(k,5)。Value=Replace(LCase(fct),“x”,单元格(k,1)。Value)
或者您希望在单元格中显示公式吗?没有任何变化。不幸的是,我已经尝试了这些组合。单元格(k,5)保持为空。k=i到i+6的输入错误-