|
本帖最后由 yvll 于 2024-5-20 20:32 编辑
以下代码是统计Z2:BV2中数字在A:V每行中的出现次数,并显示在Y列,但总是没有显示,请教是哪里错了,谢谢!
注:X列和Z列都有数据。
Sub JC_Click()
Application.ScreenUpdating = False
r = [a65536].End(xlUp).Row
r2 = Split(Range("IV1").End(xlToLeft).Address(1, 0), "$")(0)
h = Application.WorksheetFunction.Count(Sheet2.Range("Z2:BV2"))
If h >= 1 Then
wrr = Range("z2").CurrentRegion
arr = Range("a10").CurrentRegion
[Y4].CurrentRegion.ClearContents
n = 0
e = UBound(arr)
e1 = UBound(wrr, 2)
ReDim qrr(1 To e - 1)
Sheet2.Range("a1:v" & r).Interior.Pattern = xlNone '清空颜色
For i = 2 To e
For j = 3 To 22
For k = 1 To e1
If arr(i, j) = wrr(1, k) Then
Cells(i + 2, j).Interior.ColorIndex = 33
n = n + 1
Exit For
End If
Next
Next
qrr(i - 1) = n
n = 0
Next
[Y4].Resize(e - 2, 1) = WorksheetFunction.Transpose(qrr)
End If
End Sub
|
|