Results 1 to 3 of 3

Thread: Get PercentRank of a selected range?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Get PercentRank of a selected range?

    Hi to the forum...


    I only occasionally use VBA so, as usual, I am not coding this correctly. My goal is to select a range, and then output (to a nearby cell on the same row)the percentrank of each cell in the range. The range is a one-column range. so, for example, column 1 contains a list of 5 values. I got the basics of the input box from another macro I did years ago. i don't really remember much about it. Apparently PercentRank doesn't like what I am doing. I have tried a lot of formulations but code will not compile. Here's the macro. Any help, and, if possible, an explanation, would be greatly appreciated:

    [vba]Sub TestPctRank1()
    ' TestPctRank1 Macro
    ' Macro recorded 5/28/2011 by
    'Dim Myrange As Range
    Dim mycount
    Dim Mycounter
    Dim MyPercentRank

    Set Myrange = Application.InputBox(Prompt:="range:", Type:=8) Set StartCell = Myrange.Cells(1, 1) Set EndCell = Myrange.Cells(Myrange.Rows.Count, 1) mycount = Myrange.Rows.Count Mycounter = 1
    ActiveCell.Activate
    MyPercentRank = PercentRank(Myrange, Myrange.Cells(Mycounter, 1).Value) ActiveCell.Value = MyPercentRank
    Do Until Mycounter = mycount
    Mycounter = Mycounter + 1
    ActiveCell.Offset(1, 0).Activate
    ActiveCell.Value = MyPercentRank
    Loop
    End Sub[/vba]
    Last edited by Aussiebear; 05-29-2011 at 12:14 AM. Reason: Added VBA Tags

Posting Permissions

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