|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 一把小刀闯天下 于 2018-8-23 16:04 编辑
Option Explicit
Sub test()
Dim arr, i, j, m
arr = Sheets("sheet1").[a1].CurrentRegion
ReDim brr(1 To UBound(arr, 1), 1 To 2)
For i = 2 To UBound(arr, 1)
If Len(arr(i, 1)) Then
m = m + 1: brr(m, 1) = 1: brr(m, 2) = arr(i, 1)
For j = i + 1 To UBound(arr, 1)
If arr(i, 1) = arr(j, 1) Then brr(m, 1) = brr(m, 1) + 1: arr(j, 1) = vbNullString
Next
End If
Next
With Sheets("sheet2").[a2]
.Resize(Rows.Count - 1, 2).ClearContents
If m > 0 Then .Resize(m, 2) = brr
End With
End Sub
|
|