|
- Sub 序号()
- Dim arr
- Dim lLastRow&
- Dim lCount&, i&
- On Error GoTo ErrorHandler
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Application.EnableEvents = False
- lLastRow = Cells(Rows.Count, 2).End(xlUp).Row
- Columns(5).ClearContents
- arr = Range("a1:e" & lLastRow)
- Range("a1:e" & lLastRow).ClearContents
- For i = LBound(arr) To UBound(arr)
- If arr(i, 1) = "序号" Then
- lCount = lCount + 1
- arr(i, 5) = lCount
- End If
- Next
- Range("a1").Resize(UBound(arr), UBound(arr, 2)).Value = arr
- Application.ScreenUpdating = True
- Application.DisplayAlerts = True
- Application.EnableEvents = True
- MsgBox "OK", vbInformation + vbOKOnly
- Exit Sub
- ErrorHandler:
- MsgBox Err.Number & vbCrLf & _
- Err.Description
- End Sub
复制代码 |
|