您可以使用
isNumeric
检查它是否是一个数字。如果它返回
True
,然后跳过它。否则您可以继续。
此外,我强烈建议您摆脱
.Activate
并声明您的工作表,然后改用该声明。
请参见下面的代码修改:
Sub deletezeros()
Dim i As Integer
Dim isin As String
Dim valor As Long
Dim longitud As Long
'Declare your worksheet
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("2. Con.EMISION")
'Avoid using .Activate in lieu of using ws
Worksheets("2. Con.EMISION").Activate
'Use With ws (optional) for better code clarity
With ws
For i = 200 To 1 Step -1
If IsNumeric(.Cells(i, 4)) = False Then
isin = .Cells(i, 4).Value
longitud = Len(isin)
valor = .Cells(i, 8).Value
If valor = 0 And longitud = 12 Then
.Rows(i & ":" & i).Delete
End If
End If
Next i
End With
End Sub