+ Reply to Thread
Results 1 to 10 of 10

Need to append name from sheet1 column A with Sheet2 column A and past unique names in Sht

  1. #1
    Forum Contributor
    Join Date
    09-15-2014
    Location
    london
    MS-Off Ver
    2013
    Posts
    111

    Need to append name from sheet1 column A with Sheet2 column A and past unique names in Sht

    Hi,

    Can anyone please help me with this.
    I need a macro that can copy list of names from Sheet1 column "A" to Sheet2 column "A"
    Note: Need to append names from sheet1 to sheet2
    Finally only unique names should be pasted in sheet3 Column A from Row 6...

    Attached excel for your reference...

    Please advise.
    Attached Files Attached Files

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Need to append name from sheet1 column A with Sheet2 column A and past unique names in

    There is no sheet3.. do you mean employees? also, unique names from where? In the list from sheet1 or sheet2?
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Need to append name from sheet1 column A with Sheet2 column A and past unique names in

    The first part of the request, copy from Sheet1 to Sheet2:

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    09-15-2014
    Location
    london
    MS-Off Ver
    2013
    Posts
    111

    Re: Need to append name from sheet1 column A with Sheet2 column A and past unique names in

    Thanks, First part works great...

    Now I need to remove duplicates from Sheet2 and only unique names from sheet2 has to be pasted in employees sheet from column "A" row "6" onwards..

    Please advise.

  5. #5
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Need to append name from sheet1 column A with Sheet2 column A and past unique names in

    Sorry... to clarify, Sheet2 needs to have duplicates removed? Or you simply mean that only unique values from sheet2 should be copied to employees?
    Also, next time you run the macro, should it clear employees and start over, or in future it should paste values below last name on employees?

  6. #6
    Forum Contributor
    Join Date
    09-15-2014
    Location
    london
    MS-Off Ver
    2013
    Posts
    111

    Re: Need to append name from sheet1 column A with Sheet2 column A and past unique names in

    Hi,

    I mean that only unique values from sheet2 should be copied to employees
    and next time I run the macro, it should paste values below last name on employees...
    Please advise.
    And Note: it should past from row "6" in employee sheet.

  7. #7
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Need to append name from sheet1 column A with Sheet2 column A and past unique names in

    I believe this should do it?

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    09-15-2014
    Location
    london
    MS-Off Ver
    2013
    Posts
    111

    Re: Need to append name from sheet1 column A with Sheet2 column A and past unique names in

    Hi Thanks,

    But when I try to have unique names pasted in sheet 7, it is not pasting... please let me know what is wrong in below code.


    Private Sub CommandButton1_Click()
    Dim alastrow As Long, blastrow As Long, clastrow As Long, k As Long, i, m, make As Long
    Dim duplicate As Boolean

    alastrow = Worksheets("EMP Date Specific").Range("A" & Rows.Count).End(xlUp).Row

    make = Worksheets("Sheet11").Range("A" & Rows.Count).End(xlUp).Row

    k = blastrow + 1
    'copy names from sheet1 to sheet2, starting at first empty cell on sheet2
    For i = 4 To alastrow
    Worksheets("Sheet11").Range("A" & k).Value = Worksheets("EMP Date Specific").Range("A" & i).Value
    k = k + 1
    Next i


    blastrow = Worksheets("PDR Date Specific").Range("B" & Rows.Count).End(xlUp).Row
    k = blastrow + 1
    'copy names from sheet1 to sheet2, starting at first empty cell on sheet2
    For i = 4 To alastrow
    Worksheets("PDR Date Specific").Range("B" & k).Value = Worksheets("Sheet11").Range("A" & i).Value
    k = k + 1
    Next i
    blastrow = Worksheets("PDR Date Specific").Range("A" & Rows.Count).End(xlUp).Row 'to get row of new last value in sheet2
    For i = 2 To blastrow 'to go through all names in sheet2
    duplicate = False
    clastrow = Worksheets("Sheet7").Range("A" & Rows.Count).End(xlUp).Row
    If clastrow < 6 Then clastrow = 5
    For k = 6 To clastrow 'to loop through Employees sheet
    If Worksheets("PDR Date Specific").Range("B" & i).Value = Worksheets("Sheet7").Range("A" & k).Value Then
    duplicate = True
    GoTo dupe
    End If
    Next k
    dupe:
    If duplicate = False Then Worksheets("Sheet7").Range("A" & clastrow + 1).Value = Worksheets("PDR Date Specific").Range("B" & i).Value
    Next i



    End Sub
    Attached Files Attached Files

  9. #9
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    861

    Re: Need to append name from sheet1 column A with Sheet2 column A and past unique names in

    Quote Originally Posted by aleanboy View Post
    Hi,

    I mean that only unique values from sheet2 should be copied to employees
    and next time I run the macro, it should paste values below last name on employees...
    Please advise.
    And Note: it should past from row "6" in employee sheet.

    Hi there!

    Maybe this will help you avoid duplicates ?:
    Please Login or Register  to view this content.
    this will bring only distinct values in sheet Employees, but if you want each time to add the distinct list to the existing list in Employees then:
    Please Login or Register  to view this content.
    Last edited by bulina2k; 10-06-2014 at 07:47 AM.
    .. and don't forget to have fun!
    Bogdan.

    mark SOLVED and Add Reputation if my answer pleases you

  10. #10
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Need to append name from sheet1 column A with Sheet2 column A and past unique names in

    aleanboy, still having issues? Pease use code tags (the # symbol in the menu above when you are typing a message) so we can read your code better.

    In my code k=blastrow +1 comes AFTER setting up the value for blastrow. Your code has k=blastrow +1 way before blastrow = ....

    EDIT:

    Also, in the PDR Date Specific (what i used as sheet 2?), the employee names are in column B? Because one of your lines of code, when we RECALCULATE blastrow, you have specified A instead of B, which might mean you are getting lastrow from an empty column?
    Last edited by Arkadi; 10-06-2014 at 01:55 PM.

+ 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] copy data from sheet1 to sheet2 based on column (A) sheet1 and column (C) sheet2
    By AWITCHER in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 05-13-2014, 03:20 PM
  2. [SOLVED] Take Data From Column on Sheet1 and Insert Into Next Blank Row on Sheet2 Then Clear Sheet1
    By abutler911 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-09-2013, 06:30 PM
  3. Replies: 1
    Last Post: 12-30-2012, 07:52 PM
  4. [SOLVED] Simple formula to match column A, sheet1, with column A, sheet2, return text answer
    By Connie5761 in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 11-14-2012, 02:56 PM
  5. Search Sheet2 Column A For Value In Textbox On Sheet1 Then Offset Right By 1-5 Column
    By sweetrevelation in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-08-2009, 01:32 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