+ Reply to Thread
Results 1 to 8 of 8

compare data in one sheet to others and move cells based on a rule

  1. #1
    Registered User
    Join Date
    01-25-2016
    Location
    UK
    MS-Off Ver
    2013
    Posts
    49

    compare data in one sheet to others and move cells based on a rule

    Is there a way that a Macro could be written to:

    a) Look at the first name and surname in each row, compare it to the Known As and Surname in the MIS sheet and if it cannot find it remove the whole row from the first sheet and put it in the next blank row in sheet called Leavers?

    b) Repeat for all sheets that begin with a P or Ante

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,777

    Re: compare data in one sheet to others and move cells based on a rule

    Could you attach a copy of your file? It would be easier to help and test possible solutions.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Registered User
    Join Date
    01-25-2016
    Location
    UK
    MS-Off Ver
    2013
    Posts
    49

    Re: compare data in one sheet to others and move cells based on a rule

    Here you go.

    So Ronald MacDonald should move to LEavers as shold Lightning McQueen.
    Attached Files Attached Files

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,777

    Re: compare data in one sheet to others and move cells based on a rule

    In sheet P4, the first name and surname are in columns F and G respectively. In sheet Ante, the first name and surname are in columns H and I respectively. If these 2 sheets are the only sheets you want compared to the MIS sheet, then it's not a problem. However, if you will have additional sheets beginning with a P or an A, then this creates a problem because there is no consistency in the location of the names. In order to build an efficient macro the organization of the data should be consistent. In other words, the first name and surname should be in the same columns in each sheet. When looping through sheets, if there is no consistency, you have to write a separate loop for each individual sheet and this makes the macro rather long and cumbersome. Also, if in future you add additional sheet, the macro will have to be modified. Would it be possible to modify the two sheets and any additional sheets you may add beginning with P or A so that the names are in the same columns in each sheet?

  5. #5
    Registered User
    Join Date
    01-25-2016
    Location
    UK
    MS-Off Ver
    2013
    Posts
    49

    Re: compare data in one sheet to others and move cells based on a rule

    These are dummy sheets to protect data sensitivity. Let me check tomorrow where the column headings are on the real sheets and I will get back to you

    Thanks

  6. #6
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,777

    Re: compare data in one sheet to others and move cells based on a rule

    No problem.

  7. #7
    Registered User
    Join Date
    01-25-2016
    Location
    UK
    MS-Off Ver
    2013
    Posts
    49

    Re: compare data in one sheet to others and move cells based on a rule

    Okay

    Changed attachment.

    Should be H and I throughout.
    Attached Files Attached Files

  8. #8
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,777

    Re: compare data in one sheet to others and move cells based on a rule

    Try this macro. After you run it, some of your data in the "Leavers" sheet may be in the wrong column but that is because the columns don't match. You will have to standardized the location of the column headers in each sheet, leaving the names in columns H & I.
    Please Login or Register  to view this content.
    Last edited by Mumps1; 09-01-2017 at 10:55 AM.

+ 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. Trying to move a row from one sheet to another based on a cells status
    By stiffanyj in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-22-2016, 03:00 PM
  2. Macro to find/compare data and move data from one sheet to the other
    By cory0789 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-11-2015, 01:31 PM
  3. Move a row to a new sheet based on a cells value.
    By jgroathouse in forum Excel General
    Replies: 6
    Last Post: 10-31-2014, 06:49 PM
  4. How to compare and move data from one sheet to another
    By cgonzo1970 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-28-2014, 07:45 PM
  5. compare data and move it to new sheet
    By savio in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 07-28-2014, 09:02 PM
  6. Compare two cells, if equal move a third cells data to another cell
    By eriick in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-24-2013, 05:38 PM
  7. Loop through cells compare values add and move to another sheet
    By begilhang in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-22-2010, 04:07 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