+ Reply to Thread
Results 1 to 5 of 5

Using RANK function in VBA code

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    07-12-2013
    Location
    Los angeles, CA
    MS-Off Ver
    Excel 2007
    Posts
    109

    Using RANK function in VBA code

    I'm getting an error stating 'Unable to get Rank function...etc'

    Is my syntax incorrect? My variable 'howmany' stores a value of 146, so it shouldn't be resulting from that. I'm stumped here.

    For Each cell In Range("K4", Range("K" & Rows.Count).End(xlUp))
                cell.Formula = Application.WorksheetFunction.Rank(Range("J" & cell.Row), Range("J4:J" & howmany))
                If cell.Offset(, -1).Value <= 0.6 Then
                    With cell.Interior
                        .Pattern = xlSolid
                        .PatternThemeColor = xlThemeColorAccent6
                        .ThemeColor = xlThemeColorDark1
                        .TintAndShade = -0.249977111117893
                        .PatternTintAndShade = 0.599993896298105
                    End With
                End If
            Next

  2. #2
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Using RANK function in VBA code

    Can you post your file?

  3. #3
    Forum Contributor
    Join Date
    07-12-2013
    Location
    Los angeles, CA
    MS-Off Ver
    Excel 2007
    Posts
    109

    Re: Using RANK function in VBA code

    Book2.xlsx Here is the worksheet I am working with (sans VBA code since the full file is far too big to post)

  4. #4
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Using RANK function in VBA code

    your vba works fine for me. Maybe because you didn't declare your variables?

    Dim cell As Range
    Dim howmany As Long

  5. #5
    Forum Contributor
    Join Date
    07-12-2013
    Location
    Los angeles, CA
    MS-Off Ver
    Excel 2007
    Posts
    109

    Re: Using RANK function in VBA code

    No, that didn't fix it unfortunately. Is there a different syntax in which i can write this?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] rank function
    By rhmjsh in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-22-2013, 10:34 AM
  2. Rank then color code
    By ccmballroom in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-28-2010, 04:09 PM
  3. rank function
    By regularjordon in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-03-2008, 05:28 PM
  4. Rank Function
    By Andrew C in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-15-2006, 02:15 AM
  5. rank function
    By donl in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-21-2005, 05:59 PM

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