Hi,
My code is working to add some columns to a spreadsheet then put the rank number in each of the new columns.
My problem is that the data being ranked will vary in its row location.
I am at a loss of how to get rank to work on variables, can any please help me with what I'm doing wrong as I cant get the rank function to work on dynamic variables.
The commented lines in my code are my failed attempts at getting to work. I have it working for a static positing, but this isn't always correct.
Thank you for reading & hope you can help me !
Antony
'insert columns for batting
'start of row
sor = Row
'end of row
eor = Row + noofstores
Do While mycolumn < 24
Cells(1, mycolumn).Select
ActiveCell.EntireColumn.Insert
Cells(12, mycolumn) = "Batting"
For rowchk = sor To eor
'This code does work but the data isnt always in the same position, so doesnt always work
Cells(rowchk, mycolumn) = "=RANK(RC[-1],R22C[-1]:R40C[-1])"
'An alternative try that doesnt work
'Cells(rowchk, mycolumn) = Application.WorksheetFunction.Rank(Range(cells(rowchk,mycolumn), Range("A1:A6"))
'An alternative try that doesnt work
'Cells(rowchk, mycolumn) = Application.WorksheetFunction.Rank(Cells(rowchk, mycolumn), Cells(sor, mycolumn), Cells(eor, mycolumn))
'An alternative try that doesnt work
'Cells(rowchk, mycolumn) = "=RANK(RC[-1],"Cells(sor, mycolumn)"," Cells(eor, mycolumn)")"
Next rowchk
mycolumn = mycolumn + 2
Loop
My code is working to add some columns to a spreadsheet then put the rank number in each of the new columns.
My problem is that the data being ranked will vary in its row location.
I am at a loss of how to get rank to work on variables, can any please help me with what I'm doing wrong as I cant get the rank function to work on dynamic variables.
The commented lines in my code are my failed attempts at getting to work. I have it working for a static positing, but this isn't always correct.
Thank you for reading & hope you can help me !
Antony
'insert columns for batting
'start of row
sor = Row
'end of row
eor = Row + noofstores
Do While mycolumn < 24
Cells(1, mycolumn).Select
ActiveCell.EntireColumn.Insert
Cells(12, mycolumn) = "Batting"
For rowchk = sor To eor
'This code does work but the data isnt always in the same position, so doesnt always work
Cells(rowchk, mycolumn) = "=RANK(RC[-1],R22C[-1]:R40C[-1])"
'An alternative try that doesnt work
'Cells(rowchk, mycolumn) = Application.WorksheetFunction.Rank(Range(cells(rowchk,mycolumn), Range("A1:A6"))
'An alternative try that doesnt work
'Cells(rowchk, mycolumn) = Application.WorksheetFunction.Rank(Cells(rowchk, mycolumn), Cells(sor, mycolumn), Cells(eor, mycolumn))
'An alternative try that doesnt work
'Cells(rowchk, mycolumn) = "=RANK(RC[-1],"Cells(sor, mycolumn)"," Cells(eor, mycolumn)")"
Next rowchk
mycolumn = mycolumn + 2
Loop