问题
Very new to VBA and trying to do a simply copy/paste special loop. How would you write the code so that each time it loops it copies one cell down in the Filter Out Pitchers tab and pastes special one cell down in the Batter Comparison tab?
Sub Hitters()
For i = 1 To 500
Worksheets("Filter Out Pitchers").Range("B2").Copy
Worksheets("Batter Analysis").Paste _
Destination:=Worksheets("Batter Analysis").Range("B1")
Worksheets("Batter Analysis").Range("A88:AA88").Copy
Worksheets("Batter Comparison").Range("A2:AA2").PasteSpecial xlPasteValues
Next i
End Sub
回答1:
Not sure I understood completely, but this may be what you're after:
For i = 1 To 500
Worksheets("Filter Out Pitchers").Range("B" & (1+i)).Copy _
Destination:=Worksheets("Batter Analysis").Range("B2")
Worksheets("Batter Comparison").Range("A" & (1+i) & ":AA" & (1+i)).Value = _
Worksheets("Batter Analysis").Range("A88:AA88").Value
Next i
来源:https://stackoverflow.com/questions/41580980/copy-paste-special-loop-in-vba