+ Reply to Thread
Results 1 to 2 of 2

R1C1 with variables and the Rank Function.

  1. #1
    Registered User
    Join Date
    06-01-2013
    Location
    United States
    MS-Off Ver
    Excel 2011
    Posts
    64

    R1C1 with variables and the Rank Function.

    So need a code that will rank many different lines of data. This was my try at it but it's giving me a 400 error. I have no idea what it doesn't like about it. I'd really appreciate any help, if you have any questions let me know. Thanks for any attempts/effort.



    Sub threemonthHoldings()

    Dim r As Integer

    Do
    r = 0

    Do
    Range("BR13").Select
    ActiveCell.FormulaR1C1 = "=rank(R[0]C[-21], R[0]C[-21 - r]:R[0]C[-9 - r], 0)"
    r = r + 1
    ActiveCell.Offset(0, 1).Select
    Loop Until IsEmpty(ActiveCell.Offset(-1, 0))

    ActiveCell.Offset(1, -12).Select

    Loop Until IsEmpty(ActiveCell.Offset(0, -9))


    End Sub

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: R1C1 with variables and the Rank Function.

    I'm not sure what formula references you want but you would use the VBA variable r within VBA and not within the actual formula. Maybe something like this.

    ActiveCell.FormulaR1C1 = "=RANK(R[0]C[-21], R[]C[" & -21 + r & "]:R[]C[" & -9 + r & "], 0)"


    Again, I don't know if this produces the range references you want, but it won't cause the 400 error.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1