Function that copy certain raws to another sheet

katani

New Member
Joined
Jul 28, 2011
Messages
1
Dear everybody,

I have a master sheet with many columns, names and numbers. one of the columns will read either 0,1,2, or any number above 2 (according to a function).

I need to make 4 new sheets in which the first sheet will copy all rows that reads 0, the second sheet should copy all rows that reads 1, the third sheet will read 2...etc.

Many thanks in advance
Katani
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
why not just sort according to THAT column and copy sets

another way is to autofilter according to 0,1,2 etc and copy filtered data to new sheets. . if there are too many numbers FIRST get unique numbers using advance filtering that column data and do autofilter looping through the unique numbers.
 
Upvote 0
Test this in a copy of your workbook.

You'll need to check the name of the 'Master' sheet and the column that contains the numbers 0, 1, 2 etc and adjust the code to suit.

Post back if you need help with how to implement the code and tell us what Excel version you are using.

<font face=Courier New><br><SPAN style="color:#00007F">Sub</SPAN> SplitMasterData()<br>    <SPAN style="color:#00007F">Dim</SPAN> wsM <SPAN style="color:#00007F">As</SPAN> Worksheet<br>    <SPAN style="color:#00007F">Dim</SPAN> i <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN><br>    <SPAN style="color:#00007F">Dim</SPAN> Crit <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN><br>    <br>    <SPAN style="color:#00007F">Const</SPAN> Col <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN> = "C" <SPAN style="color:#007F00">'<- Column with 0,1,2 etc</SPAN><br>    <SPAN style="color:#00007F">Set</SPAN> wsM = Sheets("Master") <SPAN style="color:#007F00">'<- Change to suit</SPAN><br>    <br>    Application.ScreenUpdating = <SPAN style="color:#00007F">False</SPAN><br>    <SPAN style="color:#00007F">For</SPAN> i = 0 <SPAN style="color:#00007F">To</SPAN> 3<br>        wsM.Copy After:=Sheets(Sheets.Count)<br>        Crit = IIf(i = 3, "<", "<>") & i<br>        <SPAN style="color:#00007F">With</SPAN> ActiveSheet<br>            .Name = i<br>            <SPAN style="color:#00007F">With</SPAN> Intersect(.UsedRange, .Columns(Col))<br>                .AutoFilter Field:=1, Criteria1:=Crit<br>                .Offset(1).EntireRow.Delete<br>                .AutoFilter<br>            <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>        <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>    <SPAN style="color:#00007F">Next</SPAN> i<br>    Application.ScreenUpdating = <SPAN style="color:#00007F">True</SPAN><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br><br></FONT>
 
Upvote 0

Forum statistics

Threads
1,224,578
Messages
6,179,654
Members
452,934
Latest member
mm1t1

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