程序代码:
Sub deal_data() Dim r1, n As Integer r1 = Range("a65530").End(xlUp).Row r2 = 2 For i = 2 To r1 n = Len(Cells(i, 1)) - 1 m = Len(Cells(i - 1, 1)) - 1 If r2 < 3 And Right(Cells(i, 1), 1) = 1 Then Cells(r2, 6) = Mid(Cells(i, 1), 1, n) Cells(r2, 7) = Cells(i, 2) End If If Mid(Cells(i, 1), 1, n) = Mid(Cells(i - 1, 1), 1, m) And Right(Cells(i, 1), 1) = 2 Then ' Cells(r2, 8) = Cells(i, 2) End If If Mid(Cells(i, 1), 1, n) = Mid(Cells(i - 1, 1), 1, m) And Right(Cells(i, 1), 1) = 3 Then ' Cells(r2, 9) = Cells(i, 2) r2 = r2 + 1 End If If Mid(Cells(i, 1), 1, n) <> Mid(Cells(i - 1, 1), 1, m) And Right(Cells(i, 1), 1) = 1 Then Cells(r2, 6) = Mid(Cells(i, 1), 1, n) Cells(r2, 7) = Cells(i, 2) End If Next End Sub