+ Reply to Thread
Results 1 to 12 of 12

Sorting TABS

  1. #1
    Registered User
    Join Date
    07-02-2008
    Location
    Hebburn
    Posts
    17

    Sorting TABS

    I have created a spreadsheet with over 600 sheets all individually numbered.

    I have managed to create a macro and button to click and navigate to/from sheet BUT when adding/deleting/renaming individual sheets, I still have to drag each one (or at least in groups) along the tab list to put them into numerical order.

    Is there anyway I can do this other than manually? There may also be gaps in the sequence...ie they may go...524, 550, 551, 552, 553, 605, 606, 3982 etc

    Thanks

    Andrew

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,871

    Re: Sorting TABS

    Here is a link to a solution provided by MS

    http://support2.microsoft.com/kb/812386

    and here is another solution:

    Please Login or Register  to view this content.
    Last edited by alansidman; 10-07-2014 at 04:28 PM.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Sorting TABS

    Hi,

    Here's one way

    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Registered User
    Join Date
    07-02-2008
    Location
    Hebburn
    Posts
    17

    Re: Sorting TABS

    Thanks for both replies...do these both work automatically or would i need to run a macro manually?

    Sorry, Im ok but not great with macros/VB

  5. #5
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,871

    Re: Sorting TABS

    Each would require that you run a macro.

    Here is how:

    How to install your new code
    1. Copy the Excel VBA code
    2. Select the workbook in which you want to store the Excel VBA code
    3. Press Alt+F11 to open the Visual Basic Editor
    4. Choose Insert > Module
    5. Edit > Paste the macro into the module that appeared
    6. Close the VBEditor
    7. Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)

    To run the Excel VBA code:
    1. Press Alt-F8 to open the macro list
    2. Select a macro in the list
    3. Click the Run button

  6. #6
    Registered User
    Join Date
    07-02-2008
    Location
    Hebburn
    Posts
    17

    Re: Sorting TABS

    Thanks for that Alan
    The one from Richard gave an Error 13 runtime error...dont know if its something Ive done
    Yours has sorted them but instead of starting at 500 and then 501, 502, 542, 600, 602 up to 3982, 3991, 4540, 5289 etc its placing them in 3982, 3991, 4540, 500, 501, 502, 5289, 542, 600, 602 etc
    Any thoughts or is it still me doing something wrong

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

    Re: Sorting TABS

    Instead of starting at 500 and then 501, 502, 542, 600, 602 up to 3982, 3991, 4540, 5289 etc its placing them in 3982, 3991, 4540, 500, 501, 502, 5289, 542, 600, 602 etc
    Excel treats all your sheet names as strings, not numbers. So a string starting with 3 is sorted before a string starting with 5.

    Two ways to solve your problem are:
    a. Permanently rename all 3 digit Tab names to include a leading ZERO, all 2 digit tab names to include 2 leading ZEROS. Sort.
    b. Temporarily rename all 3 digit Tab names to include a leading ZERO, all 2 digit tab names to include 2 leading ZEROS. Sort. Remove leading ZEROs from Tab names.

    Lewis

  8. #8
    Forum Contributor Cerbera's Avatar
    Join Date
    07-06-2010
    Location
    Rotorua, New Zealand
    MS-Off Ver
    Excel 2007, 2013, 2016 & 365
    Posts
    137

    Re: Sorting TABS

    Try using this code to sort all of the sheets works for sheets which are numbers or text:

    Please Login or Register  to view this content.

  9. #9
    Valued Forum Contributor
    Join Date
    07-07-2014
    Location
    Washington DC
    MS-Off Ver
    2007
    Posts
    1,047

    Re: Sorting TABS

    If you can install add-ins, I love the navigation pane included in kutools for excel. Makes it very easy to navigate through files with lots of tabs and allows you to sort them any way you'd like.

    http://www.extendoffice.com/product/...xcel-list.html

  10. #10
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Sorting TABS

    Quote Originally Posted by ajm5807 View Post
    Thanks for that Alan
    The one from Richard gave an Error 13 runtime error...dont know if its something Ive done
    Yours has sorted them but instead of starting at 500 and then 501, 502, 542, 600, 602 up to 3982, 3991, 4540, 5289 etc its placing them in 3982, 3991, 4540, 500, 501, 502, 5289, 542, 600, 602 etc
    Any thoughts or is it still me doing something wrong
    Hi,

    on which line do you get the error?
    Are any of your sheets not numerics? e.g. do you have any sheets which contain an alpha character? If so remove any reference to CLng()

    Please Login or Register  to view this content.
    Last edited by Richard Buttrey; 10-08-2014 at 09:09 AM.

  11. #11
    Registered User
    Join Date
    07-02-2008
    Location
    Hebburn
    Posts
    17

    Re: Sorting TABS

    Hi...sorry for not getting back sooner!

    Thanks for all the help...the macro from Cerbera seems to have done the job I wanted

    Richard: yes, I did have a couple of sheets with alpha names...sorry I didn't explain that in the original message

    Thanks again to all that replied

    Andrew

  12. #12
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Sorting TABS

    Quote Originally Posted by ajm5807 View Post
    Hi...sorry for not getting back sooner!

    Richard: yes, I did have a couple of sheets with alpha names...sorry I didn't explain that in the original message

    Andrew
    ..in which case removal of the CLng will perform the sorting. i.e.
    Please Login or Register  to view this content.

+ 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. Sorting Tabs
    By LS Flowers in forum Excel General
    Replies: 2
    Last Post: 05-25-2008, 06:10 AM
  2. sorting the tabs
    By SP in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-09-2006, 10:35 PM
  3. [SOLVED] Sorting Worksheet Tabs
    By Jaqi in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 02:05 AM
  4. Sorting Tabs
    By Greg B in forum Excel General
    Replies: 2
    Last Post: 04-26-2005, 11:06 AM
  5. [SOLVED] sorting tabs
    By Suz in forum Excel General
    Replies: 1
    Last Post: 01-11-2005, 03:06 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