|
如此试试
- Private Sub Worksheet_Change(ByVal Target As Range)
- Dim reg
- Set reg = CreateObject("VBScript.RegExp")
- Dim A$, i%
- Dim arr '
- Dim b
- '************ 刚加的代码 *************
-
- Dim NewInt As Long
- NewInt = Cells(Rows.Count, 2).End(xlUp).Row
- 'If ActiveCell.Row > NewInt Then Exit Sub
-
-
- '************************************
- Application.EnableEvents = False
- Application.ScreenUpdating = False
-
- Set reg = CreateObject("vbscript.regexp")
- A = Selection.Address
- With reg
- .Global = True
- .Pattern = "\d{1,3}"
- Set arr = .Execute(A)
- End With
- If Target.Column < 8 Then
- If Target.Row < 4 Then GoTo 100
- For i = arr(0) To arr(arr.Count - 1)
- Macro (i)
- Next
- Macro (Target.Row)
- Call 编号
- Call 汇总
- End If
- If Target.Column > 2 And (Target.Column = 9 Or Target.Column = 10) Then
- If Target.Row < 4 Then GoTo 100
- Call 汇总
- End If
- Application.ScreenUpdating = True
- '************ 刚加的代码 *************
-
- Dim NewInt2 As Long
- NewInt = Cells(Rows.Count, 2).End(xlUp).Row
- NewInt2 = Cells(Rows.Count, 7).End(xlUp).Row
- If NewInt2 > NewInt Then
- Range(NewInt + 1 & ":" & NewInt2).Delete
- End If
-
- '************************************
-
- 100
- Application.EnableEvents = True
-
- End Sub
复制代码 |
|