Hello and thank you for your time and help,
I am trying to create a function which would extract a subset from a given range depending on the values contained in another range. The final aim is to be able to use the Percentrank function on dynamically changeable groups
<tbody>
</tbody>
The idea would to have something like Percentrank(subset(B2:B4, C2:C4, 1), B2) with the subset function returning the subset as a range.
I have started with something like this but am stuck on a few issues:
Function Subset(x As Range, y As Range, V As String) As Range
Dim z As Range
Dim c As Range
For Each c In x
' I don't see how to refer to the equivalent cell in y:
If ??.Value = Valeur Then
If Not z Is Nothing Then
Set z = Union(z, c)
Else
Set z = c
End If
End If
Next
'Even with a simple example I am unable to return a range:
Subset = z
End Function
Thank you in advance for your help
I am trying to create a function which would extract a subset from a given range depending on the values contained in another range. The final aim is to be able to use the Percentrank function on dynamically changeable groups
A | B | C | D | |
1 | Country | GPB | Group | Percentrank |
2 | Albania | 5000 | 1 | ? |
3 | France | 28000 | 2 | |
4 | Romania | 6000 | 1 | |
5 | US | 34000 | 2 |
<tbody>
</tbody>
The idea would to have something like Percentrank(subset(B2:B4, C2:C4, 1), B2) with the subset function returning the subset as a range.
I have started with something like this but am stuck on a few issues:
Function Subset(x As Range, y As Range, V As String) As Range
Dim z As Range
Dim c As Range
For Each c In x
' I don't see how to refer to the equivalent cell in y:
If ??.Value = Valeur Then
If Not z Is Nothing Then
Set z = Union(z, c)
Else
Set z = c
End If
End If
Next
'Even with a simple example I am unable to return a range:
Subset = z
End Function
Thank you in advance for your help