Sub counter()
Dim num As Long, val As String, rng As Range
For Each cell In Sheets(2).Range("a1:a50")
If cell.Value <> "" Then
num = 0
val = cell.Text
For Each rng In Sheets(1).Range("a1:a50")
If rng.Value = val And rng.Offset(0, 1).Value = True Then
num = num + 1
End If
Next rng
cell.Offset(0, 1).Value = num
End If
Next cell
End Sub
|