+ Reply to Thread
Results 1 to 10 of 10

Move Rows from one sheet to another sheet without having duplicate entries

  1. #1
    Registered User
    Join Date
    08-15-2012
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    40

    Move Rows from one sheet to another sheet without having duplicate entries

    Hi Guys,

    I need to move the rows from one sheet to another sheet upon clicking the ‘Submit’ button.

    I will manually update my efforts in ‘Sheet 1’ and when I click ‘Submit’, it should “copy” the rows to the next sheet (Sheet 2). However, it should not duplicate the entries irrespective of clicking Submit multiple times. Obviously, while clicking ‘Submit’ it should check the entry for that particular employee name and date in the ‘Sheet 2’ and remove that completely and update the new entries and this should avoid duplicates for that date. Every time when I add new entries for a different name and for dirrerent employee, it should keep appending the Sheet 2.

    In addition, it should avoid copying the blank rows from Sheet 1 (S. No column will not be blank usually) to Sheet 2.

    All this should happen upon clicking the Submit button.

    Please help me with the macro code.

    Please let me know if you need more details. I have attached my sample sheet for reference.


    Thanks,
    Vijay N
    Attached Files Attached Files
    Last edited by vij8y; 04-16-2014 at 12:50 AM.

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Move Rows from one sheet to another sheet without having duplicate entries

    Copy the below code and do right click on SUBMIT Command Button and select view code and paste it.

    Close the VBA window (Alt+Q to close VBA window) and return to that sheet and check.

    Please Login or Register  to view this content.


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Registered User
    Join Date
    08-15-2012
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: Move Rows from one sheet to another sheet without having duplicate entries

    H Sixthsense,

    Thank you for your quick reply. This works perfectly for copying the 1st row. However, if I have more than one entry, it does not move to Sheet 2.

    I am sorry if I missed to mention this, a person can have several entries on a same date. So there can be same task repeated (with the same time as well) while filling the form. So, let us consider taking the complete rows without checking the duplicates while submitting.

    However, on Sheet 2, every time it copies the rows from Sheet 1, it should remove the rows for that employee name on that particular date and do a fresh copy.

    Thanks in advance for your time and support, greatly appreciated.

    Please refer my updated file.

    Vijay N
    Attached Files Attached Files

  4. #4
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Move Rows from one sheet to another sheet without having duplicate entries

    Just change this

    Please Login or Register  to view this content.
    to

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    08-15-2012
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: Move Rows from one sheet to another sheet without having duplicate entries

    H Sixthsense,

    Thank you. I updated different tasks (Task 1, Task2, etc.) for the Employee John. When I Submit the form, it copies as expected.

    However, when I changed all the tasks as ‘Task 1’, the new changes was not moved to the ‘Sheet 2’.

    We are trying to match the Employee name and date while moving to Sheet 2. If it exists in Sheet 2, we need to remove the entire rows and do a fresh copy.

    Appreciate your time and efforts.

    Vijay N

  6. #6
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Move Rows from one sheet to another sheet without having duplicate entries

    Quote Originally Posted by vij8y View Post
    We are trying to match the Employee name and date while moving to Sheet 2.
    That is what my initial code will do (Post #2)

  7. #7
    Registered User
    Join Date
    08-15-2012
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: Move Rows from one sheet to another sheet without having duplicate entries

    Thank you friend.

    I am really sorry for my ignorance. Your initial code doesn't copy more than one row to Sheet 2. After changing Array(1, 2) to Array(1, 2, 3), it copies all the rows to Sheet 2 which is fine. However, when I make edits to the tasks by changing all the tasks as "Task 1" (same name) and when I submit again, the entries in Sheet 2 remains unchanged. I am assuming that while copying, it does not remove the existing entries in Sheet 2.

    Try to work on the file which I sent and you will know what I exactly mean.

    I am really sorry as I am just a beginner with excel macros.


    Thanks,
    Vijay N

  8. #8
    Registered User
    Join Date
    08-15-2012
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: Move Rows from one sheet to another sheet without having duplicate entries

    Also, everytime I click submit, it keeps adding an entry horizontally... like A to G, H to N and so on...

  9. #9
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: Move Rows from one sheet to another sheet without having duplicate entries

    @vij8y
    In your attachment you have identical entries in the first sheet and nothing in the 2nd sheet.
    If that is reality, all you have to do is copy the last row over to the 2nd sheet although all the rows are the same and we have to assume that the last row is the latest entry.
    Attach a representative workbook with different scenarios.

  10. #10
    Registered User
    Join Date
    08-15-2012
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: Move Rows from one sheet to another sheet without having duplicate entries

    Hi jolivanes ,

    Thank you. I have attached my sample file for your reference.

    Sixthsense’s code works perfect. However, I believe it requires a little tweak to meet my requirement.

    Please refer the attached file (Move Rows_Test). I have updated the tasks for a particular date and when I click Submit, it copies all the rows to the next sheet which is good.

    However, I changed the ‘task name’ as same in my latest entry (Move Rows_Test2) for the same date. My expectation is, the latest list of entries should replace all the previous entries. This doesn’t happen. The look-up value should be ONLY ‘date’ AND ‘employee name’; tasks may be repeated.

    I have attached associated workbooks with this post.

    Thank you for looking into this.

    Regards,
    Vijay N
    Attached Files Attached Files

+ 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. macros to move duplicate rows and columns to another sheet.
    By Ravichary in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-24-2013, 12:15 PM
  2. VBA CODE to move rows from one sheet(1) to another sheet(2) based on data in cell
    By fozzieulo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-08-2013, 02:43 PM
  3. [SOLVED] Copy row from sheet 1 to next row in sheet 2. delete from sheet 1 and move rows up
    By papabob1954 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-16-2012, 09:38 PM
  4. Macro to move rows from one sheet to another sheet based on a cell vaule
    By d55272 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 10-09-2012, 03:33 PM
  5. Move data from on sheet to another keep duplicate rows
    By mrdata in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-10-2006, 07:53 PM

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