Help with Joining Ranges?

Sthrncali

Board Regular
Joined
Apr 1, 2011
Messages
226
Ok so here is what I am trying to do efficiently...

I have a worksheet with 75 rows of data and I want to insert a RANK into a column via VBA.

The issue is I want to rank Rows 1, 7, 14, 21, 28, 35, and 42 as a group. Then I want to rank rows 2-6, 8-13, 15-20, 22-27, 29-34, and 36-41 as a group.

So the first ranking would have ranks 1- 7 and the second group would have ranks 1-35.

Does that make sense?

I can insert the values into a different spreadsheet and rank them there, then VLOOKUP that table to get the values back to the original, but I thought using a JOIN might be more efficient - problem is I don't have much experience joining ranges..

Any help? :)
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Hi

I'm not sure I understood correctly but, with your values in column A, this code inserts the formulas in column B:

Code:
Sub WrRank()
Dim r As Range
 
Set r = Range("$A$1,$A$7,$A$14,$A$21,$A$28,$A$35,$A$42")
r.Offset(0, 1).FormulaR1C1 = "=RANK(RC[-1],(" & r.Address(ReferenceStyle:=xlR1C1) & "))"
Set r = Range("$A$2:$A$6,$A$8:$A$13,$A$15:$A$20,$A$22:$A$27,$A$29:$A$34,$A$36:$A$41")
r.Offset(0, 1).FormulaR1C1 = "=RANK(RC[-1],(" & r.Address(ReferenceStyle:=xlR1C1) & "))"
End Sub
 
Upvote 0
You can use worksheet functions to do it as well.

If you CTRL click all of the cells that you want (1, 7, 14, 21, 28, 35, and 42), you can then set those cells as a named range.

In the cells in row 1, 7, 14 etc, you can use the rank function and it will only rank those rows.

=RANK(A1,YourNamedRange,1)
 
Upvote 0

Forum statistics

Threads
1,214,617
Messages
6,120,541
Members
448,970
Latest member
kennimack

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