在用户选择中查找所有不同的值 - Excel VBA [英] Find all distinct values in user based selection - Excel VBA
本文介绍了在用户选择中查找所有不同的值 - Excel VBA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
0 | 有没有一种快速简单的方法来选择Excel中的VBA中给定选择中的所有不同值?我们| 0
- + ---- + -
we | 0 | 1
- >结果应为{0,we,1}
非常感谢您的解决方案:
解决方案
>
Option Explicit
公共子测试()
Dim cell As Object
Dim d作为对象
设置d = CreateObject(Scripting.Dictionary)
对于每个单元格在选择
d(cell.Value)= 1
下一个单元格
MsgBox d.count& 选择中的唯一项目(& Join(d.Keys,,)&)
End Sub
is there a quick and easy way to select all distinct values within a given selection in Excel with VBA?
0 | we | 0
--+----+--
we| 0 | 1
-> the result should be {0,we,1}
Many thanks in advance
解决方案
by the way I've found another solution:
Option Explicit
Public Sub Test()
Dim cell As Object
Dim d As Object
Set d = CreateObject("Scripting.Dictionary")
For Each cell In Selection
d(cell.Value) = 1
Next cell
MsgBox d.count & " unique item(s) in selection (" & Join(d.Keys, ",") & ")"
End Sub
这篇关于在用户选择中查找所有不同的值 - Excel VBA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文