|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 ilymyself521 于 2018-11-18 23:03 编辑
如图中所述,怎么能够实现,感谢!
感谢二楼提醒,使用字典已经实现了,下面是我自己编写的程序,虽然程序不咋地,但是功能没问题,还有待完善!
D列可以随便排序,在A列新增的项通过按按钮可以拷贝到D列的最底端
Private Sub CommandButton1_Click()
Dim i As Integer, j As Integer, k As Integer, l As Integer, m As Integer, d As Object, arr1, arr2, arr3, rng As Range
Set d = CreateObject("scripting.dictionary")
i = Range("A1").CurrentRegion.Rows.Count
j = Range("D1").CurrentRegion.Rows.Count
arr1 = Range("A1:A" & i)
arr2 = Range("D1:D" & j)
For k = 1 To j
d(arr2(k, 1)) = arr2(k, 1)
Next
For l = 1 To i
If Not d.exists(arr1(l, 1)) Then d(arr1(l, 1)) = arr1(l, 1)
Next
m = d.Count
arr3 = (d.keys)
Range("d1").Resize(m) = Application.Transpose(arr3)
End Sub
|
|