I have a report where I need to take part of the data and copy it to two different tabs. In my example below I have the Main data. If a row says add or replace under "Route Changes" column, I want certain data fields copied over into a new tab called "Route Loader", if that column says expire then I want some data fields copied over to a third tab called "Expiration Loader". If the row is blank under "Route Changes" then there is no action.
I created the macro to create the two new tabs. My plans were to make a do loop in vba to go row by row and copy fields over but I'm wondering if a filtered copy and paste would be easier or faster to run? The only catch is that in the route loader the Origin Description comes from one of three columns. It will look 1st to see if there is a zip if blank, look for a district, if blank, look for city, if blank then leave it blank. Can I write a if statement into vba but still have it as a value in the "Route Loader" tab?
Any help or code suggestions would be appreciated!
Frances
Excel 2007
I created the macro to create the two new tabs. My plans were to make a do loop in vba to go row by row and copy fields over but I'm wondering if a filtered copy and paste would be easier or faster to run? The only catch is that in the route loader the Origin Description comes from one of three columns. It will look 1st to see if there is a zip if blank, look for a district, if blank, look for city, if blank then leave it blank. Can I write a if statement into vba but still have it as a value in the "Route Loader" tab?
Any help or code suggestions would be appreciated!
Frances
Excel Workbook | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | M | |||
1 | Main Sheet | ||||||||||||||
2 | ID | Rte Pfc Order | Origin State | Origin City | Origin Zip | Origin District | Origin ID | Origin Name | Car | Rank | Rpc Start Date | Route Changes | Effective On Date | ||
3 | 123456 | RANKING | NY | NEW YORK | 100 | CAR1 | 1 | 12/06/10 | |||||||
4 | 123458 | RANKING | NY | NEW YORK | 100 | CAR2 | 2 | 03/15/11 | |||||||
5 | RANKING | NY | NEW YORK | 100 | CAR3 | 3 | Add | 6/21/2011 | |||||||
6 | 45678 | RANKING | LA | UNCLE SAM | CAR2 | 1 | 12/06/10 | Expire | 6/20/2011 | ||||||
7 | RANKING | LA | UNCLE SAM | CAR1 | 1 | Replace | 6/21/2011 | ||||||||
8 | 6 | RANKING | NY | NEW YORK | 10001 | CAR1 | 1 | 01/20/10 | Expire | 6/20/2011 | |||||
9 | RANKING | NY | NEW YORK | 10001 | CAR2 | 1 | Replace | 6/21/2011 | |||||||
10 | RANKING | NY | NEW YORK | 10001 | CAR1 | 2 | Replace | 6/21/2011 | |||||||
11 | LEAST COST | NY | NEW YORK | 10001 | 12345 | Supplier | CAR4 | 1 | Add | 6/21/2011 | |||||
12 | |||||||||||||||
13 | New Sheet called "Route Loader" | ||||||||||||||
14 | Copy the data from the Main sheet only if it says Add or Replace | ||||||||||||||
15 | Origin ID | Origin Name | Origin State | Origin Description | R or L | Carrier Preference | Rank | Start Date | |||||||
16 | NY | 100 | R | CAR3 | 3 | 06/21/2011 | |||||||||
17 | LA | UNCLE SAM | R | CAR1 | 1 | 06/21/2011 | |||||||||
18 | NY | 10001 | R | CAR2 | 1 | 06/21/2011 | |||||||||
19 | NY | 10001 | R | CAR1 | 2 | 06/21/2011 | |||||||||
20 | 12345 | Supplier | NY | 10001 | L | CAR4 | 1 | 06/21/2011 | |||||||
21 | Column G from Main Sheet | Column H from Main sheet | Column C | Col F, unless blank then G unless blank, then F or leave blank | Column B 1st letter | Column I | Column J | Column M | |||||||
22 | |||||||||||||||
23 | |||||||||||||||
24 | New Sheet called "Expiration Loader" | ||||||||||||||
25 | Copy Data from the Main sheet if it says Expire | ||||||||||||||
26 | RPC Id | Date | (N or Y) | ||||||||||||
27 | 45678 | 6/20/2011 | N | ||||||||||||
28 | 6 | 6/20/2011 | N | ||||||||||||
29 | Column A Main Sheet | Column M Main Sheet | Default N | ||||||||||||
example |