我在excel中有以下列
Sales Record Number
5100
5275
5310
5355
5357
5359
15
Seller ID: 233
我需要VBA代码只显示大于5000的行,所以'销售记录号,'15'和&应删除“卖家ID”。
我尝试了以下内容:
Sub DeleteRows()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim i As Long
For i = Range("A" & Rows.Count).End(xlUp).Row To 1 Step -1
If Not (Range("C" & i).Value < 5000) Then
Range("C" & i).EntireRow.Delete
End If
Next i
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
答案 0 :(得分:0)
在If语句中首先检查它是否为数字的调整应该做什么?
Sub DeleteRows()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim i As Long
For i = Range("A" & Rows.Count).End(xlUp).Row To 1 Step -1
If Not IsNumeric(Range("C" & i).Value) Or Range("C" & i).Value < 5000 Then
Range("C" & i).EntireRow.Delete
End If
Next i
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub