相关疑难解决方法(0)

仅限Excel VBA复制粘贴值(xlPasteValues)

我正在尝试将sheetA中的整个列复制到Sheet B. sheetA列具有使用formuls形成的值.我只使用xlPasteValues复制SheetA列值.但它不会将值粘贴到另一个sheetB.sheetB中的列为空.我的VBA代码

    Public Sub CopyrangeA()

    Dim firstrowDB As Long, lastrow As Long
    Dim arr1, arr2, i As Integer

    firstrowDB = 1
    arr1 = Array("BJ", "BK")
    arr2 = Array("A", "B")

         For i = LBound(arr1) To UBound(arr1)
        With Sheets("SheetA")
           lastrow = Application.Max(3, .Cells(.Rows.Count, arr1(i)).End(xlUp).Row)
           .Range(.Cells(1, arr1(i)), .Cells(lastrow, arr1(i))).Copy
           Sheets("SheetB").Range(arr2(i) & firstrowDB).PasteSpecial xlPasteValues
        End With
    Next
    Application.CutCopyMode = False

End Sub
Run Code Online (Sandbox Code Playgroud)

excel vba copy-paste excel-vba

28
推荐指数
2
解决办法
78万
查看次数

标签 统计

copy-paste ×1

excel ×1

excel-vba ×1

vba ×1