使用初始值将数据写入单元格

时间:2013-10-15 14:48:33

标签: vba excel-vba excel

我可以获得帮助,我正在尝试使用初始值将数据写入电子表格中的单元格,然后添加特定的增量,直到达到也指定的最大值。我在下面列举了一个例子。谢谢。

最低:0.5 最大:1.5 增量:0.1

写下面的代码,但它无限运行... sub IncrementValue()     Dim iMin,iMax,inc,x As Single

iMin = Range("A1").Value
iMax = Range("A2").Value
Inc = Range("A3").Value

Range("B1").Value = iMin
x = 1

Do
x = x + 1
Range("B" & x).Value = Range("B" & x - 1).Value + Inc
Loop Until Range("B" & x).Value = iMax

End Sub

1 个答案:

答案 0 :(得分:0)

Sub FillIncrementingSeries(rStart As Range, dMin As Double, dMax As Double, dIncr As Double)

    rStart.Value = dMin
    rStart.Resize(((dMax - dMin) / dIncr) + 1, 1).DataSeries xlColumns, xlDataSeriesLinear, , dIncr, dMax

End Sub
相关问题