+ Reply to Thread
Results 1 to 3 of 3

Need a sort maco and help fixing an existing macro

Hybrid View

  1. #1
    Registered User
    Join Date
    02-12-2010
    Location
    Toms River, NJ
    MS-Off Ver
    Excel 2010
    Posts
    42

    Need a sort maco and help fixing an existing macro

    In this thread I was suggested

    Sub SortData()
    Dim LR&
      LR = Range("A" & Rows.Count).End(xlUp).Row
        With ActiveSheet.Sort
            .SortFields.Clear
            .SortFields.Add Key:=Range("F3:F" & LR), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortTextAsNumbers
            .SortFields.Add Key:=Range("C3:C" & LR), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortTextAsNumbers
            .SetRange Range("A1:L" & LR)
            .Header = xlYes
            .Orientation = xlTopToBottom
            .Apply
        End With
    End Sub
    to sort my accounts by Utilization and keep the accounts that are at 0% utilized at the bottom of the list. It worked the first few times I tried it but now it won't. Instead when I run it by clicking the sort button with the dummy data it moves the 0% utilization to the top.

    I also want to add two more Macros. One to sort it by amount of payments needed and the other to sort it by the balance.

    When I have this working correctly I plan to offer it others to use in their own debt reduction attempts of course I would not be charging anyone for this spreadsheet.

    Any help would be appreciated.
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    11-02-2011
    Location
    Rugby, England
    MS-Off Ver
    Office 365
    Posts
    890

    Re: Need a sort maco and help fixing an existing macro

    Hello fella,

    Having looked at you sheet, your coding appears correct, it is indeed sorting everything the way it should, however, the issue lies with the formula in column F.

    Please find attached for an updated version, hope it helps!!
    If it does please click the add rep for me

    galvinpaddy.
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    11-02-2011
    Location
    Rugby, England
    MS-Off Ver
    Office 365
    Posts
    890

    Re: Need a sort maco and help fixing an existing macro

    To explain a little more, your old formula read -
    =IF(B2>0,B2/D2,""))
    Which produced a blank cell in F, and when sorted, these were at the top.
    The new formaul reads -
    =IF(B2="","",IF(B2>0,B2/D2,"0"))
    which leaves the cell blank, therefore sorting the way you wanted
    Last edited by galvinpaddy; 06-19-2012 at 03:47 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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