|
Sheets("AAA").Select
Range("A1:B2000").Sort Key1:=Range("A1"), Order1:=xlAscending, Key2:=Range( _
"B1"), Order2:=xlAscending
For i = 2 To s
For j = 1 To 10
If Cells(i, 1) = Cells(i + j, 1) Then
Cells(i, 2) = Cells(i + j, 2) + Cells(i, 2)
Rows(i + j).ClearContents
End If
Next j
Next i
Sheets("BBB").Select
Range("A1:B2000").Sort Key1:=Range("A1"), Order1:=xlAscending, Key2:=Range( _
"B1"), Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase _
:=False, Orientation:=xlTopToBottom, SortMethod:=xlPinYin, DataOption1:= _
xlSortNormal, DataOption2:=xlSortNormal
For i = 2 To t
For j = 1 To 10
If Cells(i, 1) = Cells(i + j, 1) Then
Cells(i, 2) = Cells(i + j, 2) + Cells(i, 2)
Rows(i + j).ClearContents
End If
Next j
Next i
Sheets("CCC").Select
Range("A1:B2000").Sort Key1:=Range("A1"), Order1:=xlAscending, Key2:=Range( _
"B1"), Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase _
:=False, Orientation:=xlTopToBottom, SortMethod:=xlPinYin, DataOption1:= _
xlSortNormal, DataOption2:=xlSortNormal
For i = 2 To u
For j = 1 To 10
If Cells(i, 1) = Cells(i + j, 1) Then
Cells(i, 2) = Cells(i + j, 2) + Cells(i, 2)
Rows(i + j).ClearContents
End If
Next j
Next i
我在sheets(“ddd”)中做了一个控件按钮,执行上面的程序,我的目的是对AAA\BBB\CCC进行排序,排序后对每张表中第一列重名的字段将其第二列的数值累加到重名的第一个字段上,可是在我执行完成后发现ddd也给排序了,我不想对DDD排序,这是为什么?还有程序中《Rows(i + j).ClearContents》一行代码,我的本意是将改行删除,但是删除后由于行序发生变化,导致循环执行时出现跳行现象,没有将所有应该删除的行删除,没办法,我才用了这样一条清空行内容的语句,有人能帮我改一下么
[此贴子已经被作者于2006-6-24 9:59:21编辑过]
|
|