How Can I get this to Complie RRS feed

  • Question

  • Hi All,

    I have some code that I am trying to implement.  It is a For loop that has an if else statement in it.  Basically I want to say if the cell I am looking at does is not a real number (In this case a divide by zero error) I want to loop to skip over it and iterate to the next ColIndex as listed in the loop.  The code is below.  If you could help me out that would be great.

    For ColIndex = 9 To ColMax - 2
      If ws.Cells(RowMax + 2, ColIndex).Value = "#DIV/0!" Then
        Next ColIndex
        Sample = ws.Cells(RowMax + 1, ColIndex).Value - ws.Cells(3, ColIndex).Value
        SampleA = Abs(Sample)
       If SampleA <= (Sigma * ws.Cells(RowMax + 2, ColIndex).Value) Then
            ss.Cells(RM, ColIndex - 2).Value = "Pass"
            ss.Cells(RM, ColIndex - 2).Value = "Doesn't Pass Spec"
      End If
    Next ColIndex

    Monday, February 9, 2015 8:17 PM


  • #DIV/0! is not a text string, but an error value. So comparing the value to the text string #DIV/0!" won't work.

    You could replace

      If ws.Cells(RowMax + 2, ColIndex).Value = "#DIV/0!" Then


      If IsError(ws.Cells(RowMax + 2, ColIndex).Value) Then

    This will catch ALL errors, not just #DIV/0!

    Regards, Hans Vogelaar (

    • Marked as answer by jba14baseball Monday, February 9, 2015 10:50 PM
    Monday, February 9, 2015 8:23 PM