Creating new sheets depending on contents of column

imimin

Active Member
Joined
May 9, 2006
Messages
404
Hello! Could someone help me with this project?

I need a macro that will 'examine' the contents of column 'C' (see first sample sheet below) and when it finds the text 'ITEM NUMBER' move the selection over 2 columns (column 'E') and examine the contents of that cell. If it finds the number '25', it needs to continue its search in column 'C' where it left off. If it finds a number other than '25' in column 'E' it needs to move the contents of that row and all other rows below it up to the next empty cell to another sheet. A new sheet needs to be created for each different number found. So, if the numbers '5' and '20' are found in the different cells in column 'E', 2 additional sheets need to be created with different groups of 5's and 20's (see sample source and output sheets below).

The bottom line here is that I need a sheet for each grouping of numbers '25' and additional sheet(s) for any additional number(s) that may be found in column 'E'. So, if the numbers 25, 5 and 20 are found in column 'E' adjacent to the text 'ITEM NUMBER' in column 'C', a total of 3 sheets will be created (the one we started with with some rows deleted and 2 additional sheets that are newly created).

Thank you!

Sample source:
outwitDataExport.xls
ABCDEFGHIJKLMNOPQ
1
2ITEMITEMNUMBER255075100125150Add'l25
3InvitationCSN9824C-87294.00316.00338.00360.00430.50501.0070.50
4OuterEnvelopewithPrintedReturnAddressforInvitationPRTENV37.0039.0041.0043.0051.5060.008.50
5LinedInnerEnvelopeforInvitationLINEDENV30.0060.0090.00120.00150.00180.0030.00
6ReceptionCardCSR2953C139.00146.00153.00160.00183.50207.0023.50
7RespondCardwithEnvelopeCSE2953C-15174.00186.00198.00210.00245.20280.4035.20
8InformalNoteCSI2284C-15144.00151.00158.00165.00189.60214.2024.60
9EnvelopewithPrintedReturnAddressforThankYouorInformalNotePRTENV37.0039.0041.0043.0051.5060.008.50
10SavetheDateCS8774C-91184.00191.00198.00205.00239.00273.0034.00
11
12
13
14ITEMITEMNUMBER5152535455565
15AnnouncementERP65SY-22727.0038.0049.0060.0071.0079.0084.00
16OuterEnvelopewithPrintedReturnAddressPRTENV23.9024.9025.9026.9027.9028.9029.90
17
18
19ITEMITEMNUMBER203040506070Add'l10
20InvitationMAN4782-227110.40112.90115.40117.90120.40122.9010.50
21OuterEnvelopewithPrintedReturnAddressPRTENV22.0023.0024.0025.0026.0027.002.00
22ColoredOuterEnvelopewithPrintedReturnAddressPRTCOLOR26.0029.0032.0035.0038.0041.004.00
23
24ITEMITEMNUMBER255075100125150Add'l25
25InvitationVA6960-68132.60149.70166.80183.90225.30266.7041.40
26OuterEnvelopewithPrintedReturnAddressPRTENV23.6024.6029.0033.4037.8042.204.40
27InformalNoteVAI6160-1557.0063.3069.6075.9093.00110.1017.10
28LinedEnvelopesLINEDENV5.4010.8016.2021.6027.0032.405.40
29EnvelopewithPrintedReturnAddressforThankYouorInformalNotePRTENV23.6024.6029.0033.4037.8042.204.40
30
Collection1


Sample output for 20's:
sample_output_20s.xls
ABCDEFGHIJKLMNOPQ
1ITEMITEMNUMBER20304050607080
2AnnouncementEA8993-22770.0077.0086.0093.0099.00104.00108.00
3OuterEnvelopewithPrintedReturnAddressPRTENV25.4026.4027.4028.4029.4030.4031.40
4InformalNoteEAI8956-20443.0044.0045.0046.0047.0048.0049.00
5EnvelopewithPrintedReturnAddressforThankYouorInformalNotePRTENV25.4026.4027.4028.4029.4030.4031.40
6
7ITEMITEMNUMBER20304050607080
8AnnouncementEA8932-22759.0067.0075.0082.0086.0092.0097.00
9OuterEnvelopewithPrintedReturnAddressPRTENV25.4026.4027.4028.4029.4030.4031.40
10ColoredOuterEnvelopewithPrintedReturnAddressPRTCOLOR29.4032.4035.4038.4041.4044.4047.40
11
12ITEMITEMNUMBER20304050607080
13AnnouncementEA8974-22770.0077.0086.0093.0099.00104.00108.00
14OuterEnvelopewithPrintedReturnAddressPRTENV25.4026.4027.4028.4029.4030.4031.40
15
16ITEMITEMNUMBER203040506070Add'l10
17InvitationMA4450-22781.4083.9086.4088.9091.4093.907.90
18OuterEnvelopewithPrintedReturnAddressPRTENV22.0023.0024.0025.0026.0027.002.00
19ColoredOuterEnvelopewithPrintedReturnAddressPRTCOLOR26.0029.0032.0035.0038.0041.004.00
20
Collection1


Sample output for 5's:
sample_output_20s.xls
ABCDEFGHIJKLMNOPQ
1ITEMITEMNUMBER5152535455565
2AnnouncementERP65SY-22727.0038.0049.0060.0071.0079.0084.00
3OuterEnvelopewithPrintedReturnAddressPRTENV23.9024.9025.9026.9027.9028.9029.90
4
5ITEMITEMNUMBER5152535455565
6AnnouncementERP65VP-22727.0038.0049.0060.0071.0079.0084.00
7OuterEnvelopewithPrintedReturnAddressPRTENV23.9024.9025.9026.9027.9028.9029.90
8
9ITEMITEMNUMBER5152535455565
10AnnouncementERP65XP-22727.0038.0049.0060.0071.0079.0084.00
11OuterEnvelopewithBlankReturnAddressPRTENV23.9024.9025.9026.9027.9028.9029.90
12
Collection1
 
Last edited:

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

Forum statistics

Threads
1,216,129
Messages
6,129,051
Members
449,484
Latest member
khairianr

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