View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Harry Flashman Harry Flashman is offline
external usenet poster
 
Posts: 10
Default Rank Data using VBA - having trouble with R1C1 notation

I think I figured out R1C1. This looks a bit clumsy but it seems to
work.
Now I need to learn how to select the location for the ranked data.
It's probably silly posting this since I am the only one in this
thread, but nevermind.

Sub RankData3()
Set myRange = Selection
e = InputBox("How many columns should the gap be?")
c = myRange.Columns.Count
q = myRange.Column + c - 1
t = myRange.Rows.Count + myRange.Row - 1
myRange.Copy myRange.Offset(0, c + e)
Set myData = Range(ActiveCell.Offset(1, c - 1), ActiveCell.Offset(0,
1).End(xlDown))
f = myData.Row
g = (-1 * (c + e))
myData.Offset(0, c + e).FormulaR1C1 = "=RANK(RC[" & g & "],R" & f &
"C[" & g & "]:R" & t & "C[" & g & "],0)"
End Sub