如何按所有增量增加一系列而不是增加设定百分比?

时间:2014-03-03 15:53:57

标签: excel-vba vba excel

我试图通过所有组合增加一组数字。我可以按系数百分比增加系列,但不是所有组合。

Dim a As Integer
Dim i As Integer

For a = 1 To 10
    For i = 60 To 90
        Sheets("Sheet1").Range("C2") = Sheets("Sheet1").Range("B2") * (1 + a / 1000)        
        Sheets("Sheet1").Range("C3") = Sheets("Sheet1").Range("C2") * (1 + i / 1000)            
        Sheets("Sheet1").Range("C4") = Sheets("Sheet1").Range("C3") * (1 + i / 1000)          
    Next i
Next a

因此,例如,我可以将一行增加到下一行6%然后增加7%等等。但是如果我想通过所有组合增加每一行怎么办?

1 个答案:

答案 0 :(得分:0)

Dim a As Integer
Dim i As Integer
Dim rng As Range

With Sheets("Sheet1")
    For a = 1 To 10
        Set rng = .Range("B" & a + 1)
        rng.Offset(0, 1).Value = rng.Value * (1 + a / 1000)
        Dim c As Integer: c = 2
        For i = 60 To 90
            rng.Offset(0, c).Value = rng.Offset(0, (c - 1)).Value * (1 + i / 1000)
            c = c + 1
        Next i
    Next a
End With