How to copy data into every other cell in a row?
我在转置时将单元格 (
我想粘贴到所有其他列(
1 2 3 4 5 6 7 8 9 10 11 12 | Sub CopyData() Dim wsSrc As Worksheet Dim wsDst As Worksheet Set wsSrc = Worksheets("Sheet1") Set wsDst = Worksheets("Sheet2") wsSrc.Range("B18:B23").Copy wsDst.Offset(1, 1).Range("O4").PasteSpecial xlPasteValues, Transpose:=True Application.CutCopyMode = False End Sub |
我已经把它转置了。粘贴时如何跳过所有其他列?
没有使用标准复制/粘贴方法的"跳过/转置",所以我认为最好的选择是遍历你的值并使用偏移量。这应该可以...
1 2 3 4 5 6 7 8 9 10 11 12 13 | Sub CopyData() Dim wsSrc As Worksheet, wsDst As Worksheet, aCell As Range, tOff As Long Set wsSrc = Worksheets("Sheet1") Set wsDst = Worksheets("Sheet2") For Each aCell In wsSrc.Range("B18:B23").Cells wsDst.Range("o4").Offset(0, tOff).Value = aCell.Value tOff = tOff + 2 Next aCell End Sub |