+ Reply to Thread
Results 1 to 13 of 13

how to sort tabs by month

  1. #1
    Registered User
    Join Date
    10-03-2015
    Location
    west coast is the best coast
    MS-Off Ver
    excel 2010
    Posts
    113

    how to sort tabs by month

    Hello. If I a have a bunch of tabs that are names of months, how can I order them by months. E.g. January, February, March, etc?

  2. #2
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: how to sort tabs by month

    If you literally have just 12 tabs, 1 per month, then drag and drop will be the easiest way.

    There is no built in sort function for tabs and to do it with vba would take longer to write the code than to sort them by hand (or mouse).

  3. #3
    Registered User
    Join Date
    10-03-2015
    Location
    west coast is the best coast
    MS-Off Ver
    excel 2010
    Posts
    113

    Re: how to sort tabs by month

    Oh ok. I have 60 tabs (5 years) so the dragging and dropping might take a little while. There has to be something out there. I'll keep looking on google. Thanks!!

  4. #4
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: how to sort tabs by month

    How are the tab names formatted?

    If the format is consistent, for example, January 2015 (i.e. full month name, single space, 4 digit year) then it could be coded.
    Possibly it could be done with less consistent formats, need to give it a little thought.

    I did have a quick look on google but nothing stood out as being readily available.

  5. #5
    Registered User
    Join Date
    10-03-2015
    Location
    west coast is the best coast
    MS-Off Ver
    excel 2010
    Posts
    113

    Re: how to sort tabs by month

    Yeah, the months are full names, the rest are just copies so, January (varying text) and then (1) (2) (3) for each year. Not sure if that makes sense....Basically each month is completely written out, and then has a space after it.

  6. #6
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    365 Version 2409
    Posts
    2,789

    Re: how to sort tabs by month

    Can you type out a few examples so we don't wonder.
    Varying text just leaves me guessing what you mean.

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: how to sort tabs by month

    Can you just upload a workbook with those sheets?

  8. #8
    Forum Contributor
    Join Date
    05-04-2014
    Location
    New Jersey, United States
    MS-Off Ver
    Excel 2010, 2013
    Posts
    120

    Re: how to sort tabs by month

    Not sure if this is exactly what you're looking for, but give this a try:

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    10-03-2015
    Location
    west coast is the best coast
    MS-Off Ver
    excel 2010
    Posts
    113

    Re: how to sort tabs by month

    Thanks. Mr Clabullis. I'll take a look at this tomorrow. I'm on vacay

  10. #10
    Registered User
    Join Date
    10-03-2015
    Location
    west coast is the best coast
    MS-Off Ver
    excel 2010
    Posts
    113

    Re: how to sort tabs by month

    @ Clabullis. I was trying to understand the code in your sheet but I wasn't sure what format it was "expecting". Was it something like this: Jan 4, Feb 3, Mar 2, Dec 1? I also wasn't able to follow certain pieces of the code. Please correct me where I'm wrong. You loop through years first and then months, right? What is "like" (I'm going to look this up)? I think the rest of it I get. It's looping from year 5 to year 1, and the last month in your array to the first month (Dec to Jan). Thanks!!

  11. #11
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: how to sort tabs by month

    As clabulis appears to be offline, I'll answer on their behalf.

    The code expects something like "Jan*(1)" where * represents any number of characters in the middle of the sheet name. This was based on your example format in post #5.

    The code loops through the sheets, then months, then years, finding the latest sheet chronologically that matches the format,"Dec*(5)", then positioning it as the first sheet.

    Next cycle of the loop, it finds the previous month, same year, "Nov*(5)", then positions that as the first sheet, with the "Dec*(5)" sheet being bumped down to second.

    Process is repeated for each remaining sheet / month / year until "Jan*(1)" is pushed into first position, which should then have sorted the sheets in the correct order.

    "Like" looks for a string that looks "Like" the sample that you are comparing to, with "Dec*(5)" as the string to compare, it looks for something that starts with "Dec", ends with "(5)" and has anything, from 0 to an unknown number of characters (represented using the "*" wildcard) in between.

  12. #12
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: how to sort tabs by month

    Quote Originally Posted by elmasguapo View Post
    January (varying text) and then (1) (2) (3) for each year.
    Try
    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    10-03-2015
    Location
    west coast is the best coast
    MS-Off Ver
    excel 2010
    Posts
    113

    Re: how to sort tabs by month

    @ Jason thanks. Makes sense.

    @ jindon. I'll take a look at this code later today. Thanks!!

+ 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] Pivot: Replace month numbers with month names and sort by fiscal year
    By jomili in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-29-2011, 02:13 PM
  2. Excel 2007 : Sort tabs
    By scout13 in forum Excel General
    Replies: 3
    Last Post: 10-07-2011, 06:29 PM
  3. Dynamic labelling of tabs with day,date,month
    By cloudraines in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-18-2010, 07:44 AM
  4. [SOLVED] Is it possible to sort the tabs in a workbook?
    By Jules in forum Excel General
    Replies: 1
    Last Post: 08-03-2006, 02:55 PM
  5. [SOLVED] Sort tabs
    By Stan in forum Excel General
    Replies: 3
    Last Post: 04-26-2006, 01:25 PM
  6. Is there a way of Making monthly tabs without typing each month?
    By UCAPERSinAlaska in forum Excel General
    Replies: 4
    Last Post: 12-07-2005, 02:20 PM
  7. pulling data into a month of worksheets, two tabs per day
    By lillian in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-25-2005, 08:05 PM
  8. [SOLVED] Sort the Tabs
    By A-Design in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-13-2005, 07:05 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