以下是引用power100在2005-4-12 13:06:00的发言:
龙三哥!我的工程量汇总表搞定了吗!
你的代码我帮你写了,请看
(看你里面的代码,水平应该不错,不可能这个做不好?这段代码是从最后往上循环,每次判断一个范围,然后对其进行排序,比较第三列是否相同)
对代码具体就不解释了
Sub 汇总()
Dim i%, istar%, iend%
Dim sht As Worksheet
Application.ScreenUpdating = False
Set sht = Sheets("计算")
With Sheets("汇总")
.Cells.Delete
sht.Cells.Copy .[a1]
istar = .[c65536].End(xlUp).Row
Do Until istar <= 4
iend = .Cells(istar, 1).End(xlUp).Row + 1
.Range(.Cells(iend, 2), .Cells(istar, 7)).Sort key1:=.Cells(iend, 3)
For i = istar To iend + 1 Step -1
If .Cells(i, 3) = "" Then .Rows(i).Delete
If .Cells(i, 3) = .Cells(i - 1, 3) Then
.Cells(i - 1, 5) = .Cells(i - 1, 5) + .Cells(i, 5)
.Rows(i).Delete
End If
Next i
istar = iend - 2
Loop
End With
Application.ScreenUpdating = True
End Sub
B9CfaERn.rar
(17.03 KB, 下载次数: 237)
|