Capturing "text" instead of the formula

B

Bishop

I have the following code snippet:

Pass = 0
Fail = 0
For i = 9 To (ZeroRow - 3) Step 8
If Cells(i, "H").Value = Pass Then
Pass = Pass + 1
Else
Fail = Fail + 1
End If
Next

The cells I'm referring to actually have formulas in them but when you look
at the worksheet the cells have either "Pass" or "Fail" in them. That's what
I'm trying to capture. But when I run this code it doesn't see "Pass" in any
of the cells so all of them in the for loop get assigned to Fail. I've tried
putting the word Pass in quotes:

If Cells(i, "H").Value = "Pass" Then

but that doesn't work either. How can I fix this?
 
M

Mike H

Hi,

Try this

Dim Pass As Long, i As Long
Dim Fail As Long, ZeroRow As Long
Pass = 0
Fail = 0
For i = 9 To (ZeroRow - 3) Step 8
If UCase(Cells(i, "H").Value) = "PASS" Then
Pass = Pass + 1
Else
Fail = Fail + 1
End If
Next


--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top