+ Reply to Thread
Results 1 to 2 of 2

Writing a Macro that allows you to Sort an indefinite amount of rows

  1. #1
    Registered User
    Join Date
    06-19-2017
    Location
    Texas
    MS-Off Ver
    2013
    Posts
    33

    Writing a Macro that allows you to Sort an indefinite amount of rows

    Right now I have a macro which will sort a specific selection of rows the way I want them which is great:

    Sub Sequence()
    Range("B20:S24").Sort key1:=Range("J20:J24"), _
    order1:=xlAscending, key2:=Range("M20:M24"), _
    order2:=xlDescending, Header:=xlNo
    End Sub

    However, I might need to enter more data or less data than the 5 rows I have in the macro already. I want the macro to be robust enough for a user to enter any amount of records and be sorted correctly. Any thoughts on how to make my macro more general?

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Writing a Macro that allows you to Sort an indefinite amount of rows

    Maybe:

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

+ 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. How do I select and copy ranges of indefinite numbers of rows based on sets of criteria?
    By patricia hatton in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-02-2013, 10:11 AM
  2. Need help in writing a Macro to sort the columns in the worksheet
    By shanvin in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-27-2013, 01:04 AM
  3. [SOLVED] Help on writing a Macro to delete rows with certain criteria
    By cf7046 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-25-2012, 06:45 PM
  4. Writing a macro to sum different length rows
    By nsutton1981 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-11-2010, 04:47 AM
  5. Writing Large amount of data to Excel using VBA
    By meghakuruvilla in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-25-2009, 04:46 AM
  6. Writing a macro that deletes blank rows
    By britt@wjg in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-11-2008, 02:33 PM
  7. writing a macro to hide rows
    By Bob_Warner in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 09-25-2008, 09:43 AM
  8. Macro Help - Indefinite Rows
    By piano.lisa in forum Excel General
    Replies: 3
    Last Post: 08-16-2006, 12:50 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