简体   繁体   中英

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

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.

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM