Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditional -Question 1

Status
Not open for further replies.

coltaalex

Technical User
Jul 2, 2010
61
US

Why this code is not working ?, i mean the "for loop"

it doesn't like the "count if"





Application.Goto Reference:="R11C16:R10000C16"
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=COUNTIF(Code,P11)=0"
Selection.FormatConditions(Selection.FormatConditions.count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False



Dim N As Long, i As Long
i = 0
For N = 11 To 21
If countif(Cells(N, 16).Text) = "" Then
i = i + 1

Exit For
Else

End If
Next N

If i > 0 Then
MsgBox ("Hello")
End If

Range("P11").Select


End Sub
 
"=COUNTIF(Code,P11)=0"
What is Code ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I'd replace this:
If countif(Cells(N, 16).Text) = "" Then
with this:
If Application.WorksheetFunction.CountIf(Range("Code"), Cells(N, 16).Text) = 0 Then

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top