Count Not Equal
If inicijaliDT
is a one-column range, you can do one of the following:
Sub testLoop()
Dim cel As Range
Dim brojRedaka As Long
inicijali = wsNOSTROSheet.Range("R" & brojac).Value
For Each cel In inicijaliDT.Cells
If cel.Value <> inicijali Then
brojRedaka = brojRedaka + 1
End If
Next cel
'Debug.Print brojRedaka
End Sub
Sub testCountIf()
Dim brojRedaka As Long
inicijali = wsNOSTROSheet.Range("R" & brojac).Value
brojRedaka = inicijaliDT.Rows.Count _
- Application.CountIf(inicijaliDT, inicijali)
'Debug.Print brojRedaka
End Sub
If inicijaliDT
is a multi-column range and you are trying to count the number of rows where inicijali
is not found in any of their cells, you can do one of the following:
Sub testRowLoop()
Dim RowRange As Range
Dim cel As Range
Dim brojRedaka As Long
Dim isFound As Boolean
inicijali = wsNOSTROSheet.Range("R" & brojac).Value
For Each RowRange In inicijaliDT.Rows
For Each cel In RowRange.Cells
If cel.Value = inicijali Then
isFound = True
Exit For
End If
Next cel
If isFound Then
isFound = False
Else
brojRedaka = brojRedaka + 1
End If
Next RowRange
'Debug.Print brojRedaka
End Sub
Sub testRowMatch()
Dim RowRange As Range
Dim brojRedaka As Long
inicijali = wsNOSTROSheet.Range("R" & brojac).Value
For Each RowRange In inicijaliDT.Rows
If IsError(Application.Match(inicijali, RowRange, 0)) Then
brojRedaka = brojRedaka + 1
End If
Next RowRange
' Debug.Print brojRedaka
End Sub