我无法根据自己的情况调整此代码。我想创建一个函数,允许我计算列中重复项的数量(我相信它目前只计算行数)。 非常感谢!
Function CountPairs(rng As Variant) As Integer
Dim v As Variant
Dim count, length, i As Integer
Dim found As Boolean
count = 0
found = False
v = rng
length = UBound(v, 2)
For i = 1 To length
' Count if second of pair
If Not (IsEmpty(v(1, i))) Then
If found Then
count = count + 1
found = False
Else
found = True
End If
Else
found = False
End If
Next i
CountPairs = count
End Function
答案 0 :(得分:0)
为什么不将您希望将重复项计算的范围复制到新工作表中,转置它然后应用RemoveDuplicates
函数 - 您的重复项数将为Selection.Rows.Count - (WorksheetFunction.CountA (Selection)/Selection.Columns.Count))
答案 1 :(得分:0)