细胞类型不匹配

时间:2017-05-16 18:25:55

标签: excel vba excel-vba for-loop type-mismatch

我需要一个for循环来跳过索引值,我不明白为什么这段代码不会跳过循环中的第6个索引值。

Application.ScreenUpdating = False
Exceptions = 0
Dim i As Long
For i = 1 To Rows.Count
    If i <> 6 Then
        If (Cells(i, Selection.Column).Value - Cells(i + 1, Selection.Column).Value) > 0.1 And Cells(i, Selection.Column).Value > 90 Then
            MsgBox ("The ticker start value is: " & i - 6)
            Exit For
        End If
    End If
    If Cells(i, Selection.Column) = "" Then
        Exceptions = Exceptions + 1
    End If
    If Exceptions > 8 Then
        MsgBox ("No start found")
        Exit For
    End If
Next
Application.ScreenUpdating = True

我遇到的问题是第6行包含文本,布尔值对单元格进行数学运算。因此,当循环到达第6行时,它会崩溃。然而,尽管假设不需要处理第6行中的任何内容,但这个循环仍然继续崩溃。

0 个答案:

没有答案