Counting cells that are blank and not equal to 0

  • I cannot figure out how to make this count right. I'm looking for a count of true blank cells. Here is the code.


    Code
    For i = 2 To lastRow
            If IsEmpty(lotusRawData.Cells(i, 5)) = True Then
                If lotusRawData.Cells(i, 5).Value <> 0 Then
                    x = x + 1
                End If
            End If
    Next i


    I know the count should be 57 but it's returning 2212 because it's also including the 0's.

  • Re: Counting cells that are blank and not equal to 0


    Figured out another method. I did this instead...


    Code
    For i = 2 To lastRow
            If IsEmpty(lotusRawData.Cells(i, 5)) = False Then
                x = x + 1
            End If
        Next i
        
        y = lastRow - x - 1


    I had to use the minus 1 after the x because for some reason the headers were causing an issue in the count. Now I'm getting the right answer.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!