Hi all,
I have the below macro which extracts a unique list.
Is there any way to add a condition to this, so that the unique list only consists of names where Named_range_1 = Named range 2?
Both of these named ranges aren't in the existing code below
Thanks!
I have the below macro which extracts a unique list.
Is there any way to add a condition to this, so that the unique list only consists of names where Named_range_1 = Named range 2?
Both of these named ranges aren't in the existing code below
Thanks!
Code:
Sub Get_unique_portfolio_codes()
Dim v
v = getUniqueArrayPortfolio(Range("Aladdin_portfolio_full_name"))
If IsArray(v) Then
Range("B5").Resize(UBound(v)) = v
End If
End Sub
Public Function getUniqueArrayPortfolio(inputRange As Range, _
Optional skipBlanks As Boolean = True, _
Optional matchCase As Boolean = True, _
Optional prepPrint As Boolean = True _
) As Variant
Dim vDic As Object
Dim tArea As Range
Dim tArr As Variant, tVal As Variant, tmp As Variant
Dim noBlanks As Boolean
Dim cnt As Long
On Error GoTo exitFunc:
If inputRange Is Nothing Then GoTo exitFunc
With inputRange
If .Cells.Count < 2 Then
ReDim tArr(1 To 1, 1 To 1)
tArr(1, 1) = .Value2
getUniqueArrayPortfolio = tArr
GoTo exitFunc
End If
Set vDic = CreateObject("scripting.dictionary")
If Not matchCase Then vDic.compareMode = vbTextCompare
noBlanks = True
For Each tArea In .Areas
tArr = tArea.Value2
For Each tVal In tArr
If tVal <> vbNullString Then
vDic.Item(tVal) = Empty
ElseIf noBlanks Then
noBlanks = False
End If
Next
Next
End With
If Not skipBlanks Then If Not noBlanks Then vDic.Item(vbNullString) = Empty
End If
exitFunc:
Set vDic = Nothing
End Function