+ Reply to Thread
Results 1 to 10 of 10

Macro to Split Data Onto Separate Sheets

  1. #1
    Forum Contributor
    Join Date
    02-15-2012
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    141

    Macro to Split Data Onto Separate Sheets

    Hi, Everyone,

    I have a long list of data for numerous companies, and I'd like to separate it out onto different tabs. In the attachment, you'll see data on Tab 1 with (sample) spending for several companies. I would like to split that onto separate sheets--one sheet per advertiser.

    Would someone mind providing some help with this? It would be greatly appreciated!


    ExcelExample - Need Data Separated.xlsx

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Macro to Split Data Onto Separate Sheets

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    02-15-2012
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    141

    Re: Macro to Split Data Onto Separate Sheets

    Thanks, that's amazing! One problem though: When I run the report on the real file (which contains more than 3 companies), it works for the first three companies, then produces nearly 100 blank sheets, and towards the end of the workbook I find the additional company names.

    Any ideas?

    Again, thank you very much!

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Macro to Split Data Onto Separate Sheets

    Excel is senstive when it comes to creating names. There are many restrictions on naming excel sheets. If excel does not like the name, it just create a blank name. It will not show an error as I have included an error trapping on the code. Having known this issue for some time now, I have inlcuded on the code to delete any names which are not valid names(sheets) from the workbook. So, when ever you run the code, it will delete these empty sheets. If you see any sheet which is not company name, let me know and will have a look again.

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

    Re: Macro to Split Data Onto Separate Sheets

    Try this
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    02-15-2012
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    141

    Re: Macro to Split Data Onto Separate Sheets

    Thanks for putting that together. Unfortunately, I"m getting an error after Company 3. I tried debugging and it pointed to this line:

    "Sheets.Add(after:=Sheets(Sheets.Count)).Name = e"

  7. #7
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Macro to Split Data Onto Separate Sheets

    Do you still have issues with my code?

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

    Re: Macro to Split Data Onto Separate Sheets

    Quote Originally Posted by kestefon View Post
    "Sheets.Add(after:=Sheets(Sheets.Count)).Name = e"
    When you debug, what was the name, variable e ?
    You can move the cursor over "e" and name should come up.

    Notice:
    You can not use the string such as:
    1) Exceeds the length of 31 characters.
    2) Contains invalid character(s). i.e "?", "\", "/", "[", "]", "*", ":"

  9. #9
    Forum Contributor
    Join Date
    02-15-2012
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    141

    Re: Macro to Split Data Onto Separate Sheets

    Thanks, jindon. In this case the sheet had one of the invalid characters.

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

    Re: Macro to Split Data Onto Separate Sheets

    Then you need to delete it, no choice.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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