|
本帖最后由 小年玩卡 于 2018-10-18 22:00 编辑
Private Sub Worksheet_Change(ByVal Target As Range)
Dim i&
If Target.Column <= 7 Then
If Target.Row > 5 And Target.Row <= 52 Then
For i = 6 To 52
Cells(i, 12) = Cells(i, 2) - Cells(i, 2) * Cells(i, 6) - Cells(i, 7)
Cells(i, 11) = Cells(i, 2) - Cells(i, 12)
Next
End If
If Target.Row > 53 And Target.Row <= 100 Then
For i = 54 To 100
Cells(i, 12) = Cells(i, 2) - Cells(i, 2) * Cells(i, 6) - Cells(i, 7)
Cells(i, 11) = Cells(i, 2) - Cells(i, 12)
Next
End If
If Target.Row > 101 And Target.Row <= 148 Then
For i = 102 To 148
Cells(i, 12) = Cells(i, 2) - Cells(i, 2) * Cells(i, 6) - Cells(i, 7)
Cells(i, 11) = Cells(i, 2) - Cells(i, 12)
Next
End If
If Target.Row > 149 And Target.Row <= 196 Then
For i = 150 To 196
Cells(i, 12) = Cells(i, 2) - Cells(i, 2) * Cells(i, 6) - Cells(i, 7)
Cells(i, 11) = Cells(i, 2) - Cells(i, 12)
Next
End If
If Target.Row > 245 And Target.Row <= 293 Then
For i = 246 To 292
Cells(i, 12) = Cells(i, 2) - Cells(i, 2) * Cells(i, 6) - Cells(i, 7)
Cells(i, 11) = Cells(i, 2) - Cells(i, 12)
Next
End If
If Target.Row > 293 And Target.Row <= 340 Then
For i = 294 To 340
Cells(i, 12) = Cells(i, 2) - Cells(i, 2) * Cells(i, 6) - Cells(i, 7)
Cells(i, 11) = Cells(i, 2) - Cells(i, 12)
Next
End If
If Target.Row > 341 And Target.Row <= 388 Then
For i = 342 To 388
Cells(i, 12) = Cells(i, 2) - Cells(i, 2) * Cells(i, 6) - Cells(i, 7)
Cells(i, 11) = Cells(i, 2) - Cells(i, 12)
Next
End If
If Target.Row > 389 And Target.Row <= 436 Then
For i = 390 To 436
Cells(i, 12) = Cells(i, 2) - Cells(i, 2) * Cells(i, 6) - Cells(i, 7)
Cells(i, 11) = Cells(i, 2) - Cells(i, 12)
Next
End If
If Target.Row > 437 And Target.Row <= 484 Then
For i = 438 To 484
Cells(i, 12) = Cells(i, 2) - Cells(i, 2) * Cells(i, 6) - Cells(i, 7)
Cells(i, 11) = Cells(i, 2) - Cells(i, 12)
Next
End If
If Target.Row > 485 And Target.Row <= 532 Then
For i = 486 To 532
Cells(i, 12) = Cells(i, 2) - Cells(i, 2) * Cells(i, 6) - Cells(i, 7)
Cells(i, 11) = Cells(i, 2) - Cells(i, 12)
Next
End If
If Target.Row > 533 And Target.Row <= 580 Then
For i = 534 To 580
Cells(i, 12) = Cells(i, 2) - Cells(i, 2) * Cells(i, 6) - Cells(i, 7)
Cells(i, 11) = Cells(i, 2) - Cells(i, 12)
Next
End If
End Sub
能简化吗?现在循环下来计算也变慢了,如何优化?
|
|