maybe so
![]()
Sub Count_Names() Dim vaRoster() As Variant, vaNames() As Variant, vaPNames() As Variant Dim i As Long, vaCount As Long, x As Variant 'I have a range on one sheet which I have added to an array vaRoster = ActiveSheet.Range("C5:D24").Value '...and another range on another sheet added to an array vaNames = Sheets("Name_Matrix").Range("B5:C68").Value With CreateObject("Scripting.Dictionary") .CompareMode = 1 For i = 1 To UBound(vaNames) If vaNames(i, 1) = "P" Then .Item(vaNames(i, 2)) = 1 '(just fill the dictionary) Next i For Each x In vaRoster If Len(x) > 0 Then If .Exists(x) Then 'If value in array matches value in 2nd array vaCount = vaCount + 1: ReDim Preserve vaPNames(1 To vaCount) '(3rd array is one-dimensional array) vaPNames(vaCount) = x '...I want to add that value to a 3rd array. End If End If Next x End With MsgBox vaCount 'or MsgBox UBound(vaPNames) End Sub











LinkBack URL
About LinkBacks
Register To Reply
Bookmarks