Sort Rows with Certain Criteria to Various Worksheets

sunday_storyteller

Board Regular
Joined
Jun 22, 2007
Messages
51
I have a worksheet that we'll call "Main". I this worksheet, there are 12 columns.

Of those 12 columns, A thru L, I need to separate them out into separate based on 20 distinct values that can appear (multiple times or none at all for each value) in column B. (Note: If it would make it easier, I can re-arrange to make Column A the column with the criteria to sort these by. It would be a pain, but I can do it.)

Based on what is in Column B, I need the workbook to be sorted into the distinct subset workbooks, pulling only columns B, C, and G from the original. (The rest of the columns are used elsewhere in the workbook for calculations, so I need them to stay in the "Main" sheet, but I don't need them in the subset workbooks.
I further need it to not only sort these into individual workbooks based on column B, but also to only grab those rows that have a set value ("2" in my workbook) in column J...even though column J is not itself one that needs to be copied over...it's only a criteria determining what is copied.

Can this be done? I know I can do it with a combination of If statement and Vlookup, but if I do it that way, then any rows that don't qualify to be sorted into a particular workbook instead show up blank, so my data comes out with blank row, blank row, blank row, row with data (it qualifed with the if/vlookup), blank row, blank row, data row, etc.

My "Main" sheet usually has somewhere around 1,000 rows, and I have 20 different sheets to sort it into. I have to do this weekly, so I'm not inclined to sort/filter/copy/paste every time I need the report published.

Any help will be greatly appreciated.

I can't post an example because I don't have the necessary permissions to install anything (including the program to display worksheets) onto my computer. I can send you an example if you'd like, as I know that's an incredibly complicated question...and more complicated with no example.

Thanks!

Calinda
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
I would suggest looking at Advanced Filtering to do what you are after.
Good example of Advanced Filter steps here:
http://www.contextures.com/xladvfilter01.html

Advanced Filter allows you to preset filter options.
It also allows you to filter by criteria in ways standard autofilter can not do. You can choose an export location in the dialog box or in VBA code.
Once you setup the code and criteria, you can use a macro button to copy data from one page to the other.
 
Upvote 0
Thank you. This solution works beautifully. Now I have a follow-up question:

The data I am filtering updates every week. (The source database for the filter.) When I update that, will the filter automatically be applied to all the other worksheets to sort things into them? Or do I have to run the filter again (via macro, most likely) every time the source data changes?

Thanks!

Calinda
 
Upvote 0
You are correct, when new data is added to your "database", you will have to run the Advanced Filter again. If you use code to add to your database you can add addition code to run the Advanced Filter and have them both updated at the same time. It depends on your need to adjust filter criteria and export location in the filter. I like to keep the operations separate.
 
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,369
Members
449,080
Latest member
Armadillos

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top