+ Reply to Thread
Results 1 to 6 of 6

Filter months & generate new tabs from results

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    04-22-2012
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    329

    Filter months & generate new tabs from results

    Hi all!

    I have an awesome snippet of code which looks at a column of months (mmm) & generates a new tab for each month then copies all rows using that month respectively. May be easier if you view my workbook attached. The problem I am having is the month colunm I will eventually have will be generated from column "B" which will have a series of full dates & the only way I can generate months as "mmm" is by using...
    =IF(B2,B2,"")
    ...in column "G", sadly when I use a formula to achieve this my VBA doesn't work? Is there another way to make this work? Thanks for any help guys, as always much apreciated - Marc
    Attached Files Attached Files

  2. #2
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: Filter months & generate new tabs from results

    Sub PopulateCol_G()
    With Range("G2:G" & Cells(Rows.Count, 1).End(xlUp).Row)
        .Formula = "=IF(B2="""","""",TEXT(B2,""mmm""))"
        .Value = .Value
    End With
    End Sub
    Formula: copy to clipboard
    =IF(B2="","",TEXT(B2,"mmm"))


    For interest sake...Another version of your code...
    Sub sintekJ3v16()
    Dim Data, Dict As Object, i As Long
    Set Dict = CreateObject("Scripting.Dictionary")
    With Sheet1.Cells(1).CurrentRegion
        Data = .Value
        For i = 2 To UBound(Data, 1)
            If Not Dict.Exists(Data(i, 6)) Then
                Dict.Add Data(i, 6), 1
                If Evaluate("ISREF('" & Data(i, 6) & "'!A1)") = False Then
                    Sheets.Add(, Sheets(Sheets.Count)).Name = Data(i, 6)
                Else
                    Sheets(Data(i, 6)).UsedRange.Delete
                End If
            End If
            .AutoFilter 6, Data(i, 6)
            Union(.Columns("A"), .Columns("D"), .Columns("F")).Copy Sheets(Data(i, 6)).Range("A1")
            .AutoFilter
        Next i
    End With
    End Sub
    Last edited by Sintek; 11-09-2020 at 03:41 AM.
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  3. #3
    Forum Contributor
    Join Date
    04-22-2012
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    329

    Re: Filter months & generate new tabs from results

    Hi Sintek,
    My main sheet will have the code
    =IF(B2="","",TEXT(B2,"mmm"))
    populated down column "G" for 10,000 rows, sadly when the VBA code filters, it always filters a blank page for the month code...would there be a way of doing without the month code alltogether & generating a month tab from the current dates in column "B"? Thanks again Sintek - Marc
    Last edited by matrixpom; 11-09-2020 at 05:13 PM.

  4. #4
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: Filter months & generate new tabs from results

    All works with your sample file...What is different?
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    04-22-2012
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    329

    Re: Filter months & generate new tabs from results

    Hi Sintek,

    Sorry my mistake, works perfectly!! You're a legend! Marc

  6. #6
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: Filter months & generate new tabs from results

    Glad you got it sorted...tx for rep +

+ 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] Help needed to generate & sort 2 lists of dates into months
    By Funkemduck in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-28-2019, 01:21 PM
  2. [SOLVED] Automatically Generate a number of months between two dates
    By TamHam in forum Excel General
    Replies: 5
    Last Post: 11-15-2017, 04:36 AM
  3. [SOLVED] automatically creating tabs for 12 months
    By ammartino44 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-14-2014, 12:26 PM
  4. Generate New Workbooks from Existing Tabs
    By edorris3 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-07-2012, 02:32 PM
  5. Copy pie chart into new tabs, and show the results from data on those tabs
    By Sydney Lee in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 05-23-2012, 07:50 PM
  6. Replies: 3
    Last Post: 03-31-2010, 11:47 AM
  7. [SOLVED] HOW TO i HAVE OTHER CELLS GENERATE CONSECTUIVE MONTHS
    By Cathy in Florida in forum Excel General
    Replies: 1
    Last Post: 07-15-2006, 10:17 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