+ Reply to Thread
Results 1 to 7 of 7

splitting data into multiple tabs based on column criteria

  1. #1
    Registered User
    Join Date
    02-21-2014
    Location
    Houston
    MS-Off Ver
    Excel 2010
    Posts
    21

    splitting data into multiple tabs based on column criteria

    I have testing data that I commonly need to separate out into different teachers and schools. I want to separate the file into separate sheets using criteria from a given column, and then move each sheet to a new book. (I often have to do some variation of this with a variety of files... I imagine this is a common task.) I've found the following code that does most of what I want, except for a couple things as mentioned below.

    Please Login or Register  to view this content.
    Goal #1 - it only copies one row of my header, but my header usually takes 6 or 7 rows, all of which should be copied as is into each new sheet.
    Goal #2 - I'd like it to also move each sheet to a new book

    Any assistance on accomplishing these goals would be greatly appreciated. Samples are attached and linked below. Thanks!

    Attachment 341533 (simple workbook)
    Attachment 341534 (macro-enabled with above code)

    https://drive.google.com/file/d/0B0N...it?usp=sharing (macro-enabled with the above code)
    https://drive.google.com/file/d/0B0N...it?usp=sharing (simple workbook)
    Last edited by bardobhb; 08-27-2014 at 03:59 AM.

  2. #2
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: sorting columns based on row criteria, with variable number of columns

    Hi bardobhb,

    Clear the note in cell H34 and then try this:

    Please Login or Register  to view this content.
    HTH

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  3. #3
    Registered User
    Join Date
    02-21-2014
    Location
    Houston
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: sorting columns based on row criteria, with variable number of columns

    Thank you much, that worked really well. A couple notes/questions:

    -I changed it to save as an xlsx, because otherwise I lost essential formatting when I opened the csv
    -when it copies the sheet into a new workbook it does still change some non-essential formatting - it changes the headers to yellow and removes the red cells (which were there to highlight wrong answers). I can live happily without this formatting, but it would be nice to keep. Do you know of anyway to prevent it from making these changes?

    -I often need to do this in other files where the criteria column is not H, and the sheet name is not Sheet1. The sheetname is not really a big deal, i could always just change the name of the sheet for the sake of running the macro. Is there a way to make it where I would only need to change the column in one place? I'm assuming I could do it long ways and go through and change each H in the macro.

    -Is it possible to get it to work out of my Personal.xlsb? Maybe if i change the instances of ThisWorkbook to active work book, or something of that sort? It's no big deal to past it into whatever file I'm separating, but perhaps it doesn't hurt to ask.

    These are mostly minor things, I don't mean to burden your generously given time. The code worked great, and I greatly appreciate it.

    Brent

  4. #4
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: splitting data into multiple tabs based on column criteria

    Hi Brent,

    I changed it to save as an xlsx, because otherwise I lost essential formatting when I opened the csv
    I have also incorporated this on the attached workbook.

    when it copies the sheet into a new workbook it does still change some non-essential formatting - it changes the headers to yellow and removes the red cells (which were there to highlight wrong answers). I can live happily without this formatting, but it would be nice to keep. Do you know of anyway to prevent it from making these changes?
    For some reason the color palette wasn't reconsigning the cells interior color. I have tried to replicate the color via the Fill Color icon and all seems good (I may have inadvertently missed a cell here or there).

    Is it possible to get it to work out of my Personal.xlsb? Maybe if i change the instances of ThisWorkbook to active work book, or something of that sort? It's no big deal to past it into whatever file I'm separating, but perhaps it doesn't hurt to ask.
    You could try but you'd have to make it point to the relevant workbook. I'd just leave it on whatever workbook you want.

    Regards,

    Robert
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    02-21-2014
    Location
    Houston
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: splitting data into multiple tabs based on column criteria

    Worked great, thanks so much! It still changed the formatting when moving to a new file, but I'll work around that.

  6. #6
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: splitting data into multiple tabs based on column criteria

    Worked great, thanks so much! It still changed the formatting when moving to a new file
    Strange it didn't for me

    I'm glad we were able to help in any case

  7. #7
    Registered User
    Join Date
    02-21-2014
    Location
    Houston
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: splitting data into multiple tabs based on column criteria

    From what I can tell, it has something to do with default themes or color settings that would have to be set at each computer. If I move a sheet into a file that was already opened, that has the appropriate formatting, then nothing changes. If I move it into a new file, then it changes the grey to yellow and the red to white. Oh well.

+ 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] Variable column range, based on current selection, for sorting columns
    By kshelmidine in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-16-2014, 11:46 AM
  2. Sorting data into columns based on criteria
    By loonyhat in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 12-31-2013, 02:17 PM
  3. Replies: 0
    Last Post: 05-15-2013, 09:18 AM
  4. Formula based on variable number of non-adjacent columns
    By abousetta in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-19-2010, 04:22 AM
  5. Chart based on variable number of columns
    By Scott Hamilton in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 06-05-2005, 09:40 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