|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub test()
Set d = CreateObject("scripting.dictionary")
Set dc = CreateObject("scripting.dictionary")
Dim br(), cr()
With Sheet1
ws = .Cells(Rows.Count, 1).End(xlUp).Row
ar = .Range("a1:a" & ws)
ReDim br(1 To UBound(ar), 1 To 1)
ReDim cr(1 To UBound(ar), 1 To 1)
For i = 2 To UBound(ar)
If Trim(ar(i, 1)) <> "" Then
t = d(Trim(ar(i, 1)))
If t = "" Then
k = k + 1
d(Trim(ar(i, 1))) = k
t = k
br(k, 1) = ar(i, 1)
End If
If InStr(ar(i, 1), "西") = 0 Then
tt = dc(Trim(ar(i, 1)))
If tt = "" Then
kk = kk + 1
dc(Trim(ar(i, 1))) = kk
tt = kk
cr(kk, 1) = ar(i, 1)
End If
End If
End If
Next i
.Range("d3:d1000,f3:f1000") = Empty
.[d3].Resize(k, 1) = br
.[f3].Resize(kk, 1) = cr
End With
End Sub |
|