+ Reply to Thread
Results 1 to 8 of 8

Data separation and movement question

  1. #1
    Registered User
    Join Date
    07-12-2010
    Location
    United States
    MS-Off Ver
    Excel Office 365
    Posts
    26

    Question Data separation and movement question

    Greetings Everyone!

    I have a need to separate data from one tab in a workbook and move it to the other three......I am not even sure this operation can be performed, but I thought I would ask.

    The attachment shows 4 sheets. The last tab contains the data I need to separate into the other 3 sheets. The data is delivery data that falls into 3 categories.....zero delivery, 30 sample and 50 sample. I manually separated the data from the 4th sheet into the other three so everyone could see the final product. I would like to know if there is some way of having Excel automatically separate and move the data to the correct worksheet so I don't have to do it manually. While my example sheet is small, the real sheet I am working with has 30 columns and 300 rows so the process gets time consuming when done several times a week.

    Here is what I am looking for:

    1. The 4th tab holds the 'master' data.
    2. I want all zero delivery routes moved to the first tab, no matter the sample size. (Pieces delivered would equal zero.) The zero delivery routes would be deleted out of the 4th tab.
    3. Once the zero delivery routes are moved, then I want all 30 sample size delivery routes moved to the second tab. Pieces delivered would not matter because all the zero delivery routes would have already been removed from the data. This data would be deleted out of the 4th tab
    4. I want all 50 sample delivery routes moved to the third tab. This is the data that remains after the zero delivery and 30 sample routes are removed. This data would then be deleted from the 4th tab
    5. The 4th tab would be empty when the exercise was completed.

    I left the 4th tab populated with the data to show what I start with each time.

    Please let me know if anyone needs more information in order to attempt a solution.
    Attached Files Attached Files

  2. #2
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Data separation and movement question

    Here you go:

    Attachment 261128

    I wrote a macro that will filter the data for you, and a handy little button to click to do it.

  3. #3
    Registered User
    Join Date
    07-12-2010
    Location
    United States
    MS-Off Ver
    Excel Office 365
    Posts
    26

    Re: Data separation and movement question

    Thank you very much. When I clicked on the link I received the following message:
    Error message.png

    When I clicked YES I received this message:

    Error message #2.png

    I am a very basic Excel user - although I am trying to get much better. How do I use what you have written for the "real" sheet I use daily? Its much bigger.

    How do you write a macro? Is there a resource I can go to learn?

    Thank you for your patience with this....its tough being a newbie.....

  4. #4
    Forum Expert RobertMika's Avatar
    Join Date
    06-22-2009
    Location
    Haverhill, UK
    MS-Off Ver
    Excel 2003-13
    Posts
    1,530

    Re: Data separation and movement question

    This can be done by formulas but you will have to manualy then adjust its outcome: by copy/paste in each sheet and then remove the data from Sheet4.
    If you are http://www.excelforum.com/image.php?type=sigpic&userid=125481&dateline=1392355029happy with the results, please add to the contributor's
    reputation by clicking the reputation icon (star icon).




    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.
    To undo, select Thread Tools-> Mark thread as Unsolved.
    http://www.excelaris.co.uk

  5. #5
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Data separation and movement question

    Oh sure!

    The workbook example you shared had some data connections that caused some errors.

    Row 1 & 2 on each paste-to tab is actually the criteria the macro is building off of. Make sure your book has that.


    To apply it to your own example you will first need to enable the Developer Tab. Go to File, Options, Customize Ribbon, and on the right side under Customize the Ribbon check the box down next to Developer. Hit Okay.

    You now have an extra tab at the top of the screen!

    Choose Developer, Visual Basic

    This will open a new window where you can write VBA code.

    At the top click Insert, choose Module

    Now, copy and paste this code into that screen

    Please Login or Register  to view this content.
    There are four chunks of code written here: the first three are copies, the last is the delete.

    Wherever you see Sheet4, that is the tab you are pulling from.
    The range for Sheet4 comes right after, change this to match all of your data including the headers. (for example, you might change this to A1:J5000)

    Zero, 30 Sample, and 50 sample are the places where we are pasting to.


    Now let's break down one of the chunks of code:

    Sheets("Sheet4").Range("A1:J500").AdvancedFilter _ this is pulling from Sheet4, A1:A500
    Action:=xlFilterCopy, _ this is the copy
    CriteriaRange:=Sheets("Zero").Range("J1:J2"), _ this is what determines what we copy. it's looking at tab Zero, J1 and J2
    CopyToRange:=Sheets("Zero").Range("A3"), _ this is where we are pasting to. cell A3 on Zero
    Unique:=False this is part of advanced filter. we are copying all records regardless of duplicates

    You will customize each block to match your needs.

    The last chunk is the clearing, set that range to match whatever you set the range in the first line.

    When you're done with the code, just close that window.

    Now, to run the macro you can just choose Macros under the Developer menu and run Filter. Or, you can choose Insert on the Develop Tab, and choose the upper left icon and draw a button somewhere on Sheet4, and then assign that macro to it. Now, when you click the button the macro will go off.
    Last edited by daffodil11; 08-27-2013 at 06:29 PM.

  6. #6
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Data separation and movement question

    I'm quite the VB novice myself. I can freehand very, very little code.

    If you're curious about exploring code, you can record macros by clicking the little spreadsheeet with a red dot in the lower left of your screen and perform some excel actions. When you're done, click the icon again. You can then select that macro in the Macros menu, and choose Edit instead of run. Here you can see all the actual code that was involved in the actions you made.

    From there you can slowly begin to understand the code involved by recording very short actions, and dissecting them afterwards.

    Here's a beginner's tutorial for creating a few basic macros:

    http://msdn.microsoft.com/en-us/libr...ffice.14).aspx

    The forum has a list of guides as well:

    https://www.excelforum.com/showthread.php?t=823709
    Last edited by daffodil11; 08-27-2013 at 06:27 PM.

  7. #7
    Registered User
    Join Date
    07-12-2010
    Location
    United States
    MS-Off Ver
    Excel Office 365
    Posts
    26

    Re: Data separation and movement question

    WOW! What a complete answer. I will work with the information and let you know if I have any issues. Thanks!

  8. #8
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Data separation and movement question

    No problem, glad I could help.

    We all started somewhere; I wrote my very first macro earlier this year.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Data Separation
    By ssakthish in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-11-2013, 02:34 AM
  2. Data separation from table
    By Elen_Ch in forum Access Tables & Databases
    Replies: 2
    Last Post: 09-11-2012, 07:02 AM
  3. Separation of Data in a Thread
    By don1235 in forum Excel General
    Replies: 12
    Last Post: 08-08-2010, 05:02 AM
  4. data separation
    By oxdude in forum Excel General
    Replies: 2
    Last Post: 03-01-2009, 04:52 PM
  5. [SOLVED] Cell Data Separation Question
    By natecoupons in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 12-18-2008, 01:44 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1