+ Reply to Thread
Results 1 to 5 of 5

creating tabs from a summary list of dates

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    08-14-2013
    Location
    LA Baby!!
    MS-Off Ver
    Excel 2007
    Posts
    1,598

    creating tabs from a summary list of dates

    Hello. I have in tab 1 a list of months going down column A. They are formatted Jan-12, Feb-12 etc. I would like a macro that creates a tab for each of these months but in the format Jan 2012, Feb 2012, etc. Help would be appreciated

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: creating tabs from a summary list of dates

    Maybe:

    Sub ammartino44()
    Dim i As Long
    Dim x As Date
    Dim ws As Worksheet
    Set ws = ActiveSheet
    For i = Range("A" & Rows.Count).End(3)(1).Row To 2 Step -1
        x = Range("A" & i).Value
        Sheets.Add.Name = Format(x, "mmm yyyy")
        ws.Activate
    Next i
    End Sub

  3. #3
    Forum Contributor
    Join Date
    08-14-2013
    Location
    LA Baby!!
    MS-Off Ver
    Excel 2007
    Posts
    1,598

    Re: creating tabs from a summary list of dates

    Sweet. This worked. Could you explain what each piece of the vba code is doing (I like to understand and learn)? Also, what if I wanted the order to be from oldest date tab on the left to newest date tab on the right? Thanks.

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: creating tabs from a summary list of dates

    ammartino44:

    Per your PM

    I used three variables:

    Dim i As Long
    Dim x As Date
    Dim ws As Worksheet
    i - is used to increment operations from the bottom row of Column A to 2 (there is Step -1) which tells it too increment one step at a time upwards. (ie For i = Range("A" & Rows.Count).End(3)(1).Row To 2 Step -1)

    x - is used to define each incremented value in Column A as a date. This is also used to change the formats to your required date for the added sheets name. (ie x = Range("A" & i).Value
    Sheets.Add.Name = Format(x, "mmm yyyy")



    ws - is used to identify the activesheet (ie Set ws = ActiveSheet)


    ws.Activate - reactivates the activesheet (sheet with the dates)
    Next i - increments to the next row.

    Hope that helps.

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: creating tabs from a summary list of dates

    Hello ammartino44,

    This should do what you want...
    Sub MakeNewTabs()
    
        Dim Cell    As Range
        Dim Rng     As Range
        Dim RngEnd  As Range
        Dim Wks     As Worksheet
        
            
            Set Wks = Sheet1
            
            Set Rng = Wks.Range("A1")
            Set RngEnd = Wks.Cells(Rows.Count, Rng.Column).End(xlUp)
            Set Rng = Wks.Range(Rng, RngEnd)
            
                For Each Cell In Rng
                    If IsDate(Cell) Then
                        Worksheets.Add After:=Worksheets(Worksheets.Count)
                        ActiveSheet.Name = Format(Cell, "mmm yyyy")
                    End If
                Next Cell
                
    End Sub
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

+ 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. Replies: 3
    Last Post: 01-24-2016, 09:06 AM
  2. Replies: 6
    Last Post: 08-23-2013, 04:27 PM
  3. List Summary from Series of Tabs
    By macky1730 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 03-08-2010, 03:20 PM
  4. Macro for creating tabs linked to auto summary
    By dscape in forum Excel General
    Replies: 0
    Last Post: 05-21-2009, 06:33 AM
  5. Creating summary heading list on 1 tab from multiple tabs
    By Scorpio in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-12-2008, 07:36 AM

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