+ Reply to Thread
Results 1 to 15 of 15

Macro to create separate tabs based on columns criteria

  1. #1
    Forum Contributor
    Join Date
    11-25-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    200

    Macro to create separate tabs based on columns criteria

    Attached is a sample spreadsheet in which I need a macro to create a separate tab for each customer in column A and copying/pasting the particular customer's lines over to the new tab. I need the column titles (line 1) to be at the top of each new tab as well. And ideally, the tab's name would be the customer's name. For an example, I manually created the tab Customer 4 to show one of the desired results. I want to keep the Master tab in tact if possible. Thank you.
    Attached Files Attached Files

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

    Re: Macro to create separate tabs based on columns criteria

    Try
    Please Login or Register  to view this content.
    Or AutoFilter
    Please Login or Register  to view this content.
    Last edited by jindon; 02-28-2021 at 08:10 AM.

  3. #3
    Forum Contributor
    Join Date
    11-25-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    200

    Re: Macro to create separate tabs based on columns criteria

    Thank you. And is there anything I would need to change if there were more columns as this was only a sample. Or does this encompass all potential lines and all columns?

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

    Re: Macro to create separate tabs based on columns criteria

    Just try and post back if you find anything wrong.

  5. #5
    Forum Contributor
    Join Date
    11-25-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    200

    Re: Macro to create separate tabs based on columns criteria

    It created several new tabs and then got stuck and the debug highlighted this line. I have over 1000 lines and 100 different customer.

    Sheets.Add(, Sheets(Sheets.Count)).Name = e

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

    Re: Macro to create separate tabs based on columns criteria

    No idea from just that line.

    Most probably the data in the cell.

    What kind of error message are you getting?
    If you upload a workbook that you are working with, I can find what is going wrong.

  7. #7
    Forum Contributor
    Join Date
    11-25-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    200

    Re: Macro to create separate tabs based on columns criteria

    I attached the actual file. It created 8 new tabs and then stopped. I did notice on the ones it created, the column widths didn't auto-size. Can that be done as well? Thanks a million
    Attached Files Attached Files

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

    Re: Macro to create separate tabs based on columns criteria

    That's a customer name in row 93, ALPINE SPAS P/L - AUS, you can not use those characters for sheet name.
    : \ / ? * [ ]
    Last edited by jindon; 02-28-2021 at 09:11 AM.

  9. #9
    Forum Contributor
    Join Date
    11-25-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    200

    Re: Macro to create separate tabs based on columns criteria

    Ahhhh! Got it! Thanks. Can the columns in the new tabs be set to be the same width as the master tab?

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

    Re: Macro to create separate tabs based on columns criteria

    This replace all the invalid characters for the worksheet with under score "_" and chop the length upto 31 (maximun character length for the worksheet name) when exceeds 31 characters.
    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    11-25-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    200

    Re: Macro to create separate tabs based on columns criteria

    OMG you are amazing. Thank you!!!

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

    Re: Macro to create separate tabs based on columns criteria

    You are welcome.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

  13. #13
    Forum Contributor
    Join Date
    11-25-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    200

    Re: Macro to create separate tabs based on columns criteria

    Actually, one more thing. I don't need the customer's name on every single line in the new tabs. Can I have it placed in A1 only?

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

    Re: Macro to create separate tabs based on columns criteria

    A1?
    Replace test sub with this
    Please Login or Register  to view this content.

  15. #15
    Forum Contributor
    Join Date
    11-25-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    200

    Re: Macro to create separate tabs based on columns criteria

    Amazing!!! Thanks sooooo much.

+ 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] How to Retrieve Datapoint based on criteria in three separate columns
    By IGoCougsI in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-07-2021, 01:58 AM
  2. [SOLVED] Delete rows based in three criteria in three separate columns
    By Rabbitoh in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 09-05-2020, 07:44 AM
  3. Macro for advance filter to create separate worksheet and workbook based on criteria
    By bossrockzz in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 08-18-2014, 02:36 PM
  4. Lookup value based on 2 criteria in 2 separate columns
    By mattadler22 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-17-2013, 05:59 PM
  5. [SOLVED] Using Macro to separate a spreadsheet and create tabs for each month
    By ajang in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-26-2012, 01:42 AM
  6. VBA code to sum a range based on criteria in two separate columns
    By new.vbacoder in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-17-2010, 02:16 PM
  7. MACROS: Sort by multiple criteria - Create tabs based off of criteria
    By svineyard in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-21-2009, 10:48 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