|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Private Sub Worksheet_Change(ByVal Target As Range)
Dim ar, i&, j&, iCol&, iRow&, iNum&
If Target.Count > 1 Then Exit Sub
If Intersect(Target, [A1].CurrentRegion) Is Nothing Then Exit Sub
iCol = Target.Column
iRow = Target.Row
iNum = Target.Value
If Cells(1, iCol).Value = "组号" Then
Application.ScreenUpdating = False
Application.EnableEvents = False
With [A1].CurrentRegion
ar = .Value
For i = 2 To UBound(ar)
If i > iRow Then
iNum = iNum + 1
iNum = IIf(iNum Mod 56 = 0, 56, iNum Mod 56)
.Cells(i, iCol).Value = iNum
End If
Next i
For j = iCol + 5 To UBound(ar, 2) Step 5
For i = 2 To UBound(ar)
iNum = iNum + 1
iNum = IIf(iNum Mod 56 = 0, 56, iNum Mod 56)
.Cells(i, j).Value = iNum
Next i
Next j
End With
Application.EnableEvents = True
Application.ScreenUpdating = True
End If
End Sub |
评分
-
3
查看全部评分
-
|