excel vba 用数组方法筛选不重复数据 5
展开全部
今天刚从网上学到了一段代码,应该符合你的要求,这段代码会将A1:C3区域中的数据保留不重复后转置到D列中。
Sub HB_chiefzjh()
Dim mRng$, D, c
mRng = InputBox("请输入要合并的数据范围", "要求范围", "A1:C3")
Set D = CreateObject("scripting.dictionary")
For Each c In Range(mRng)
If Not D.exists(c.Value) Then D.Add c.Value, ""
Next c
Range("d1").Resize(UBound(D.keys) + 1, 1) = WorksheetFunction.Transpose(D.keys)
D = ""
End Sub
Sub HB_chiefzjh()
Dim mRng$, D, c
mRng = InputBox("请输入要合并的数据范围", "要求范围", "A1:C3")
Set D = CreateObject("scripting.dictionary")
For Each c In Range(mRng)
If Not D.exists(c.Value) Then D.Add c.Value, ""
Next c
Range("d1").Resize(UBound(D.keys) + 1, 1) = WorksheetFunction.Transpose(D.keys)
D = ""
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询