-2

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

最小值: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

结束子

4

1 回答 1

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
于 2013-10-15T16:40:14.890 回答