小编sam*_*sam的帖子

仅限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万
查看次数

如何使用excel公式在列中获取唯一值

我有如下的Excel数据

       JID     Val

       1001    22
       1030    6
       1031    14          
       1041    8
       1001    3
       2344    8
       1030    8
       2344    6
       1041    8
Run Code Online (Sandbox Code Playgroud)

如何使用公式获得如下所示的唯一JID值?

UJID   

1001
1030
1031
1041    
2344
Run Code Online (Sandbox Code Playgroud)

excel-formula excel-2010

18
推荐指数
3
解决办法
4万
查看次数

标签 统计

copy-paste ×1

excel ×1

excel-2010 ×1

excel-formula ×1

excel-vba ×1

vba ×1