Excel VBA:在特定单元格中设置一个值,然后复制一组单元格并粘贴值,然后迭代该值

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18391978/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 16:28:12  来源:igfitidea点击:

Excel VBA: Set a value in a specific cell, then copy a set of cells and paste values, then iterate the value

excelvbaexcel-vba

提问by user2709102

I don't have any experience with Visual Basic, just a bit of Java, but I think what I'm asking is pretty simple, so I hope somebody can lend a hand.

我对 Visual Basic 没有任何经验,只有一点 Java,但我认为我的要求很简单,所以我希望有人能伸出援手。

In terms of pseudocode,

在伪代码方面,

For x=1:200

Set cell C2 in workbook "Output list" to x

Copy cells C3:C14

Paste values (just values, not the formulas) into cells (E+X)3:(E+X)14 (so, F3:F14 for x=1, G3:G14 for x=2, etc)

Is this as simple as I think it is?

这有我想的那么简单吗?

回答by tigeravatar

Hopefully this gets you going in the right direction:

希望这能让你朝着正确的方向前进:

Sub tgr()

    Dim i As Long

    With Sheets("Output list")
        For i = 1 To 200
            .Range("C2").Value = i
            .Range("E3:E14").Offset(, i).Value = .Range("C3:C14").Value
        Next i
    End With

End Sub