没有直接的方法可以像您想要的那样交错粘贴它们。但是,您可以创建一个临时 VBA 来执行您想要的操作。
例如,您可以:-
- 在 Excel 文件中创建一个 VBA 过程(如下所示)。
- 为其分配键盘快捷键(例如 Ctrl+Q)。
- 为此,请按 Alt+F8,然后选择宏,然后单击“选项”。
- 选择要复制的单元格,然后按 Ctrl+C。
- 选择要粘贴的单元格,然后按 Ctrl+Q(或您选择的任何键盘快捷键)。
- 输入要复制的次数。(在您的示例中,它将是 3。)
- 哇!:D
- 现在您可以删除 VBA 过程。:)
VBA代码:
Sub PasteAsInterleave()
Dim startCell As Range
Dim endCell As Range
Dim firstRow As Range
Dim pasteCount As Long
Dim rowCount As Long
Dim colCount As Long
Dim i As Long
Dim j As Long
Dim inputValue As String
If Application.CutCopyMode = False Then Exit Sub
'Get number of times to copy.
inputValue = InputBox("Enter number of times to paste interleaved:", _
"Paste Interleave", "")
If inputValue = "" Then Exit Sub 'Cancelled by user.
On Error GoTo Error
pasteCount = CInt(inputValue)
If pasteCount <= 0 Then Exit Sub
On Error GoTo 0
'Paste first set.
ActiveSheet.Paste
If pasteCount = 1 Then Exit Sub
'Get pasted data information.
Set startCell = Selection.Cells(1)
Set endCell = Selection.Cells(Selection.Cells.count)
rowCount = endCell.Row - startCell.Row + 1
colCount = endCell.Column - startCell.Column + 1
Set firstRow = Range(startCell, startCell.Offset(0, colCount - 1))
'Paste everything else while rearranging rows.
For i = rowCount To 1 Step -1
firstRow.Offset(i - 1, 0).Copy
For j = 1 To pasteCount
startCell.Offset(pasteCount * i - j, 0).PasteSpecial
Next j
Next i
'Select the pasted cells.
Application.CutCopyMode = False
Range(startCell, startCell.Offset(rowCount * pasteCount - 1, colCount - 1)).Select
Exit Sub
Error:
MsgBox "Invalid number."
End Sub