VBA to copy select fields from main sheet to different tabs

mcnealfbm

New Member
Joined
Jul 12, 2004
Messages
33
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 Workbook
ABCDEFGHIJKLM
1Main Sheet
2IDRte Pfc OrderOrigin StateOrigin CityOrigin ZipOrigin DistrictOrigin IDOrigin NameCarRankRpc Start DateRoute ChangesEffective On Date
3123456RANKINGNYNEW YORK100CAR1112/06/10
4123458RANKINGNYNEW YORK100CAR2203/15/11
5RANKINGNYNEW YORK100CAR33Add6/21/2011
645678RANKINGLAUNCLE SAMCAR2112/06/10Expire6/20/2011
7RANKINGLAUNCLE SAMCAR11Replace6/21/2011
86RANKINGNYNEW YORK10001CAR1101/20/10Expire6/20/2011
9RANKINGNYNEW YORK10001CAR21Replace6/21/2011
10RANKINGNYNEW YORK10001CAR12Replace6/21/2011
11LEAST COSTNYNEW YORK1000112345SupplierCAR41Add6/21/2011
12
13New Sheet called "Route Loader"
14Copy the data from the Main sheet only if it says Add or Replace
15Origin IDOrigin NameOrigin StateOrigin DescriptionR or LCarrier PreferenceRankStart Date
16NY100RCAR3306/21/2011
17LAUNCLE SAMRCAR1106/21/2011
18NY10001RCAR2106/21/2011
19NY10001RCAR1206/21/2011
2012345SupplierNY10001LCAR4106/21/2011
21Column G from Main SheetColumn H from Main sheetColumn CCol F, unless blank then G unless blank, then F or leave blankColumn B 1st letterColumn IColumn JColumn M
22
23
24New Sheet called "Expiration Loader"
25Copy Data from the Main sheet if it says Expire
26RPC IdDate(N or Y)
27456786/20/2011N
2866/20/2011N
29Column A Main SheetColumn M Main SheetDefault N
example
Excel 2007
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

Forum statistics

Threads
1,224,505
Messages
6,179,151
Members
452,891
Latest member
JUSTOUTOFMYREACH

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