Results 1 to 6 of 6

Macro for changing number of rows

Threaded View

  1. #1
    Registered User
    Join Date
    03-31-2010
    Location
    New York, New York
    MS-Off Ver
    Excel 2007
    Posts
    2

    Question Macro for changing number of rows

    Hello -

    So I'm a little less experienced than I thought.

    Below is my table.
    Item	Rate 1	Rate 2
    A	0.60%	0.30%
    B	0.50%	0.40%
    C	0.50%	0.70%
    E	0.30%	0.30%
    F	0.20%	0.50%
    My little macro orders the rows in descending order by column C, then orders the rows in descending order by Column B. But it's hard coded to 6 rows. I don't know how to make it apply to whether I have 30 records or 3,000 records. FYI, the number of columns will be fixed at 3 columns no matter how many records I have.

    Sub Ordering_Macro()
    '
    ' Ordering_Macro Macro
    '
    '
    ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sort.SortFields.Clear
    ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sort.SortFields.Add Key:=Range _
    ("C2:C6"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
    xlSortNormal
    ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sort.SortFields.Add Key:=Range _
    ("B2:B6"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
    xlSortNormal
    With ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sort
    .Header = xlYes
    .MatchCase = False
    .Orientation = xlTopToBottom
    .SortMethod = xlPinYin
    .Apply
    End With
    End Sub
    Any help would greatly be appreciated.

    Thanks for your help in advance.

    - DyingIsis
    Last edited by DyingIsis; 03-31-2010 at 11:27 PM.


LinkBacks (?)

  1. Page
    Refback This thread
    10-04-2013, 06:09 AM

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