![]() |
Macro skipping blank cell
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 --- Message posted from http://www.ExcelForum.com/ |
Macro skipping blank cell
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 "bossbubba " wrote in message ... 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 --- Message posted from http://www.ExcelForum.com/ |
All times are GMT +1. The time now is 01:13 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com