1

有人可以帮助我吗?我运行下面的模块,它工作正常,但它粘贴单元格(公式)的内容而不是值。我知道这是值的特殊粘贴,但不确定在哪里调整。另外,我想将行从跨越 A:K 的变量表中复制出来,然后粘贴到 identicle 表中。抱歉,如果不清楚,不知道为什么代码在下面显示很有趣。从子开始:

Sub armine_profitTEST()
    Dim r As Long, endRow As Long, pasteRowIndex As Long

    endRow = 500 ' of course it's best to retrieve the last used row number via a function
    pasteRowIndex = 5

    For r = 1 To endRow 'Loop through sheet1 and search for your criteria

        If Cells(r, Columns("F").Column).Value = "Armine" Then 'Found
            'Copy the current row
            Rows(r).Select
            Selection.Copy

            'Switch to the sheet where you want to paste it & paste
            Sheets("Armine").Select
            Rows(pasteRowIndex).Select
            ActiveSheet.Paste

           'Next time you find a match, it will be pasted in a new row
            pasteRowIndex = pasteRowIndex + 1

           'Switch back to your table & continue to search for your criteria
            Sheets("Summary").Select
        End If
    Next r
End Sub
4

1 回答 1

1

只需使用pasteSpecial

Dim xRng As Microsoft.Office.Interop.Excel.Range

xRng.PasteSpecial(Microsoft.Office.Interop.Excel.XlPasteType.xlPasteFormulas)
于 2013-02-28T12:58:59.270 回答