编制代码如下:
Sub 去除重复字符()
Dim I, J, K As Integer
Dim BJ As Integer
Dim s As String
Dim mya(1 To 100)
s = Cells(1, 1)
I = Len(s)
For J = 1 To I
mya(J) = Mid(s, J, 1)
Next J
s = mya(1)
For J = 2 To I
BJ = 0
For K = 1 To J - 1
If mya(J) = mya(K) Then
BJ = 1
Exit For
End If
Next K
If BJ = 0 Then
s = s + mya(J)
End If
Next J
Cells(1, 2) = s
End Sub
第1步:
将J:K的数据粘贴到O:P
选定两列数据区>数据>删除重复项>确定
*** 作后两列数据保留了唯一值
第2步:
O2输入 =LOOKUP(1,0/((J:J=O2)*(K:K=P2)),L:L)
公式下拉
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)