见代码:
Sub tongji()
Dim hh As Long, h As Long, dyg As Range
hh = [a65536].End(3).Row
Range("a1:c" & hh).Sort key1:="动作类型", key2:="达成率", Header:=xlYes
For h = 2 To hh
For Each dyg In [e8:e17]
If Cells(h, 2) = dyg.Value Then
Range(Cells(dyg.Row, 6), Cells(dyg.Row, 7)) = Array(Range("a" & h), Range("c" & h))
Range(Cells(dyg.Row + 1, 6), Cells(dyg.Row + 1, 7)) = Array(Range("a" & h + 1), Range("c" & h + 1))
Range(Cells(dyg.Row + 2, 6), Cells(dyg.Row + 2, 7)) = Array(Range("a" & h + 2), Range("c" & h + 2))
Exit For
End If
Next dyg
h = 行号(Range("b" & h))
Next h
End Sub
Function 行号(dyg As Range) As Long
Dim lie As Integer, h As Long
lie = dyg.Column
For h = dyg.Row To 65536
If Cells(h + 1, lie).Value <> Cells(h, lie).Value Then Exit For
Next h
行号 = h
End Function
|