代码放在Sheet2(数据表)中。
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column <> 14 Or Target.Row < 11 Then Exit Sub
If Target.Count > 1 Then Exit Sub
Dim r&, i&, j%
r = [n65536].End(3).Row
If Cells(r, 14) <> "" And r Mod 10 = 1 Then
i = r - 9
With Sheet1
For j = 2 To 38 Step 9
.Cells(j, 2) = Cells(i, 1)
.Cells(j, 7) = Cells(i + 1, 1)
.Cells(j, 4) = Cells(i, 7)
.Cells(j, 9) = Cells(i + 1, 7)
.Cells(j + 1, 2) = Cells(i, 2)
.Cells(j + 1, 7) = Cells(i + 1, 2)
.Cells(j + 1, 4) = Cells(i, 4)
.Cells(j + 1, 9) = Cells(i + 1, 4)
.Cells(j + 2, 2) = Cells(i, 3)
.Cells(j + 2, 7) = Cells(i + 1, 3)
.Cells(j + 3, 2) = Cells(i, 8)
.Cells(j + 3, 7) = Cells(i + 1, 8)
.Cells(j + 4, 2) = Cells(i, 6)
.Cells(j + 4, 7) = Cells(i + 1, 6)
.Cells(j + 4, 4) = Cells(i, 5)
.Cells(j + 4, 9) = Cells(i + 1, 5)
.Cells(j + 5, 2) = Cells(i, 9)
.Cells(j + 5, 7) = Cells(i + 1, 9)
.Cells(j + 5, 4) = Cells(i, 10)
.Cells(j + 5, 9) = Cells(i + 1, 10)
.Cells(j + 6, 2) = Cells(i, 11)
.Cells(j + 6, 7) = Cells(i + 1, 11)
i = i + 2
Next
End With
End If
End Sub |