我正在检查P列(从第8行开始),如果它包含“Incomplete”,那么我想删除整行,否则什么都不做,但它给了我回运行时错误6 OVERFLOW
这是我的代码:
Private Sub CommandButton3_Click()
Dim i As Integer
Dim Pvalue As String
i = 8
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Application.DisplayStatusBar = False
Application.EnableEvents = False
ActiveSheet.DisplayPageBreaks = False
lastRow = 0
lastRow = ActiveSheet.UsedRange.Row - 1 + ActiveSheet.UsedRange.Rows.Count
MSG1 = MsgBox("are you sure you want to remove the Incomplete rows?", vbYesNo, "Microsoft Excel")
If MSG1 = vbYes Then
'clearing the body table
For i = 8 To lastRow
Pvalue = Range("P" & i).value
If Pvalue = "Incomplete" Then
Worksheets("Sheet4").Range("A" & i & ":" + "P" & i).ClearContents
Worksheets("Sheet4").Range("A" & i & ":" + "P" & i).Interior.ColorIndex = 0
Else
End If
Next
Else
End If
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
Application.DisplayStatusBar = True
Application.EnableEvents = True
ActiveSheet.DisplayPageBreaks = True
End Sub
答案 0 :(得分:-1)