问题1
Private Sub CommandButton1_Click()
Dim i, j As Long
Sheets("sheet2").Cells.ClearContents
Sheets("sheet1").Cells.Copy
Sheets("sheet2").Select
Sheets("sheet2").Range("A1").Select
ActiveSheet.Paste
i = 3
Do While Sheets("sheet2").Range("A" & i).Value <> ""
For j = 2 To i - 1
If Sheets("sheet2").Range("A" & i).Value > Sheets("sheet2").Range("A" & j).Value Then
Else
Sheets("sheet2").Rows(i & ":" & i).Cut
Sheets("sheet2").Rows(j & ":" & j).Insert Shift:=xlDown
Exit For
End If
Next j
i = i + 1
Loop
End Sub
问题2
Private Sub CommandButton1_Click()
Dim i, j As Long
Sheets("sheet2").Cells.ClearContents
Sheets("sheet1").Cells.Copy
Sheets("sheet2").Select
Sheets("sheet2").Range("A1").Select
ActiveSheet.Paste
i = 3
Do While Sheets("sheet2").Range("A" & i).Value <> ""
For j = 2 To i - 1
If Sheets("sheet2").Range("C" & i).Value & Sheets("sheet2").Range("D" & i).Value > Sheets("sheet2").Range("C" & j).Value & Sheets("sheet2").Range("D" & j).Value Then
Else
Sheets("sheet2").Rows(i & ":" & i).Cut
Sheets("sheet2").Rows(j & ":" & j).Insert Shift:=xlDown
Exit For
End If
Next j
i = i + 1
Loop
End Sub