Results 1 to 5 of 5

VBA auto-sort not working when the "IFERROR" part of the formula is in effect

Threaded View

davo3286 VBA auto-sort not working... 04-08-2019, 02:03 PM
6StringJazzer Re: VBA auto-sort not working... 04-08-2019, 05:24 PM
davo3286 Re: VBA auto-sort not working... 04-08-2019, 08:07 PM
6StringJazzer Re: VBA auto-sort not working... 04-08-2019, 08:12 PM
davo3286 Re: VBA auto-sort not working... 04-08-2019, 08:16 PM
  1. #1
    Forum Contributor
    Join Date
    06-07-2018
    Location
    Newcastle Upon Tyne, England
    MS-Off Ver
    365
    Posts
    143

    VBA auto-sort not working when the "IFERROR" part of the formula is in effect

    I have VBA code to auto-sort a league table.

    My code is:

    Option Explicit
    
    Public Sub SortAll()
       SortAAA
       SortAA
       SortA
       
    End Sub
    Sub SortAAA()
       SortDivision Range("C6:P9"), Range("I6:I9")
    End Sub
        
    Sub SortAA()
       SortDivision Range("C13:P17"), Range("I13:I17")
    End Sub
        
    Sub SortA()
       SortDivision Range("C21:P24"), Range("I21:I24")
    End Sub
    
    Sub SortDivision(TotalRange As Range, KeyRange As Range)
    
       With Me.Sort
          .SortFields.Clear
          .SortFields.Add _
             Key:=KeyRange, _
             SortOn:=xlSortOnValues, _
             Order:=xlDescending, _
             DataOption:=xlSortNormal
          .SetRange TotalRange
          .Header = xlGuess
          .MatchCase = False
          .Orientation = xlTopToBottom
          .SortMethod = xlPinYin
          .Apply
       End With
        
    End Sub
    The formula in the range column that dictates the sort is:

    =IFERROR(F6/(F6+G6),".000")
    The sort works perfectly when the standard part of the formula is able to be used:

    (F6/(F6+G6)
    But when there is an error (this is because that particular team have not yet played a fixture so far this season), everything else sorts correctly and all teams that have not yet played and require the =IFERROR are sat at the top of the pile which is causing issues with the other stats in the league table.

    Any suggestions of how I can get the IFERROR teams to be included in the auto-sort? They are displaying the correct value from the formula however, not the correct playing in the league which means other formulas are now referring to the incorrect cells.

    Thanks
    Last edited by davo3286; 04-08-2019 at 02:05 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 3
    Last Post: 03-09-2019, 12:04 PM
  2. What's wrong with my formula =IFERROR('DATA EXPORT - RAW ORDERS'!B1),"")
    By preveo in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-13-2018, 09:26 AM
  3. auto populate "invoice" with part description and price from another sheet if qty=<>0
    By scott33099 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-08-2014, 11:33 AM
  4. [SOLVED] IF Formula not working - need to return "NO" if cell is 1% greater or "YES" if less 1%
    By maryren in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-26-2013, 11:34 AM
  5. [SOLVED] "IF" to "IFERROR" (or other formula) help by skipping empty cells
    By slack578 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 08-10-2013, 03:50 PM
  6. vba doesn't work with "iferror()" and formula autofill problem
    By lkim in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-10-2012, 07:47 AM
  7. Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",False)" not working
    By redders in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-31-2011, 03:52 PM

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