VBA 找出EXCEL一个区域中的不同单元格的值列成一列
RT~
祝大家国庆节快乐!
[解决办法]
明白了,例子,在B2:D6区域查找,将不重复的值写在F列
Dim l As Integer, myRange As Range, r
l = 1 'F列行计数
Set myRange = Range("B2:D6") '查找的区域范围
For Each r In myRange
If Application.WorksheetFunction.CountIf(myRange, r) = 1 Then
Range("F" & l) = r '找到后放到F列
l = l + 1 '行数+1
End If
Next r
例如B2:D6的数据为
121
243
365
487
509
运行结果:
6
8
7
0
9