我正在尝试将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数据
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)