ranking with vba

cecyTeran

New Member
Joined
Oct 25, 2017
Messages
1
Hello im trying to do a ranking with vba this is the summary of my code :

Dim RR1 As Range
Dim RG1 As Range
Dim rule1 As Variant
rule1 = ComboBox5.value
Set RR1 = ActiveSheet.Range(ActiveSheet.Range("C4").End(xlToRight).Offset(1, 6), ActiveSheet.Range("C4").End(xlToRight).Offset(1, 6).End(xlDown))
'rangetorank2 = ActiveSheet.Range(ActiveSheet.Range("C4").End(xlToRight).Offset(1, 7), ActiveSheet.Range("C4").End(xlToRight).Offset(1, 7).End(xlDown))
Set RG1 = ActiveSheet.Range(ActiveSheet.Range("C4").End(xlToRight).Offset(1, 9), ActiveSheet.Range("C4").End(xlToRight).Offset(1, 9).End(xlDown))
If rule1 = "higher is better" Then
RR1.Select
With Range("RR1").Offset(0, 3)
'.FormulaArray = "=Rank(z5:z7,z5:Z7,0)" (doing this works perfectly but as the table could have more values and not necesary will be in the Z column y was trying to run the following code but have different errors)
.FormulaArray = "=Rank((" & Range("RR1").Address & "),(" & Range("RR1").Address & ",0)"
.FormulaArray = "=Rank(RR1,RR1,0)"
(none of the two formulas above works )

End With
ElseIf ComboBox5.value = "lower is better" Then
End If
End Sub

thanks you in advance if you can give me an idea
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Code:
[B]FormulaArray = "=Rank(" & RR1.Address & "," & RR1.Address  & ",0)[/B]

Should work
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,902
Messages
6,175,278
Members
452,629
Latest member
SahilPolekar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top