用字典处理也可以方便的完成任务 Sub 保留原数据() Dim d As New Dictionary For i = 2 To 5 Set d(Cells(i, 1) & "") = Range(Cells(i, 1), Cells(i, 4)) Next For i = 1 To d.Count d(d.Keys(i - 1)).Copy Cells(i + 10, 1) Next End Sub Sub 保留原数据1() Dim d As New Dictionary For i = 2 To 5 d(Cells(i, 1) & "") = Range(Cells(i, 1), Cells(i, 4)) Next For i = 1 To d.Count Range(Cells(15 + i, 1), Cells(15 + i, 4)) = d(d.Keys(i - 1)) Next End Sub
这个应该就是smhf_6兄所表达的意思了 Sub 就地删除() Dim d As New Dictionary For i = 2 To 5 d(Cells(i, 1) & "") = i Next For Each k In d d.Key(k) = d(k) Next For i = 5 To 2 Step -1 If Not d.Exists(i) Then Rows(i).Delete Shift:=xlUp Next End Sub
[此贴子已经被作者于2007-9-30 12:37:51编辑过] |