+ Reply to Thread
Results 1 to 2 of 2

Macro to sort multiple columns in order, on any sheet/table

  1. #1
    Registered User
    Join Date
    07-03-2016
    Location
    Washington, USA
    MS-Off Ver
    2016
    Posts
    38

    Macro to sort multiple columns in order, on any sheet/table

    Below macro has been working great for me - but it's limited to only the table specified in the code. I've been trying to morph it to work in whatever table/sheet is active. I thought for sure my "ActiveTable" variable would work... What am i missing?

    Before: (Works great, but only specified table)

    Please Login or Register  to view this content.

    After: (Doesn't work )

    Please Login or Register  to view this content.
    Is this even the best way to sort these 3 fields in this certain order? The help is much appreciated.

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Macro to sort multiple columns in order, on any sheet/table

    Hi Andrewjs,

    You were close. Try the following code. I could not test the Sort routine, because I did not have a workbook with the correct data.
    Please Login or Register  to view this content.
    It is a best practice to declare all variables. If you misspell a variable in your code, VBA will silently assume it is a Variant variable and go on executing with no clue to you that you have a bug. Go to the VBA development window, click Tools, Options, and check "Require Variable Declaration." This will insert the following line at the top of all new modules:
    Please Login or Register  to view this content.
    This option requires all variables to be declared and will give a compiler error for undeclared variables.

    Lewis

+ 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] Sort in Alphabetic order for multiple columns
    By suchetherrah in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-24-2017, 01:28 AM
  2. [SOLVED] Sort multiple columns based in increasing order
    By gauti14 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-18-2016, 05:14 PM
  3. Replies: 5
    Last Post: 09-04-2016, 07:09 AM
  4. [SOLVED] Macro copying and inserting to another sheet in sort order
    By drgkt in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-29-2015, 03:30 AM
  5. Replies: 13
    Last Post: 12-19-2013, 11:06 PM
  6. Replies: 1
    Last Post: 05-23-2013, 10:16 AM
  7. Macro to Sort Based on order of a different sheet
    By _Ryan_ in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-23-2010, 12:47 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