|
楼主 |
发表于 2024-12-21 22:48
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub 统计符合条件的房屋A()
Dim ar, i&, j&, strSymbol$, isFlag As Boolean, cr, r, k, dr()
Application.ScreenUpdating = False
With Worksheets(1)
With .[a1].CurrentRegion
ar = .Value
For i = 3 To UBound(ar)
.Cells(i, 14) = Empty
isFlag = True
For j = 4 To 10
If Len(ar(i, j)) = 0 Then strSymbol = ar(2, j) Else strSymbol = ar(i, j)
If strSymbol <> ar(2, j) Then
isFlag = False: Exit For
End If
Next j
If isFlag Then .Cells(i, 14) = ar(i, 2)
Next i
End With
.Activate
End With
r = Cells(Rows.Count, "N").End(xlUp).Row
cr = Range("N3:N" & r)
ReDim dr(1 To r)
Range("N3:N" & r).ClearContents
k = 0
For i = 1 To UBound(cr)
If cr(i, 1) <> "" Then k = k + 1: dr(k) = cr(i, 1)
Next
[N3].Resize(UBound(dr), 1) = Application.Transpose(dr)
Application.ScreenUpdating = True
Beep
End Sub
我重新修改了一下代码,完全符合我的要求,谢谢大神! |
|