Macro skipping blank cell

B

bossbubba

I need help Urgently because I have tried everything and cannot make my
macro work. What I need is a Macro that will check

Let say cell a1:a15 for the letter P or F and if one cell is blank to
skip and check until 3 cells are covered.

a1 = p a2 = p a3 = a4 = f a5 = p a6 = p

I am in cell a20, I need to check cell a1:a15, if a1,a2,a3 is >2 "p" I
need "compliant" or if a1,a2,a3 <2 "p" I need "not compliant" the
problem I am having is if a1,a2 has a p or f and a3 does not etc, to
skip the blank and use the last three filled cells
 
T

Tom Ogilvy

You want to find if 3 adjacent cells contain "p" or "f"?


Sub Checkcompliance()
Dim bCompliant As Boolean
Dim i As Long
bCompliant = False
For i = 1 To 13
If Application.Sum(Application.CountIf(Cells(i, 1).Resize(3, 1),
Array("p", "f"))) = 3 Then
bCompliant = True
Exit For
End If
Next
If bCompliant Then
MsgBox "Compliant"
Else
MsgBox "Not Compliant"
End If

End Sub

Regards,
Tom Ogilvy
 

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