+ Reply to Thread
Results 1 to 10 of 10

Transfer cell values to another sheet, but need to skip duplicates

  1. #1
    Forum Contributor
    Join Date
    07-26-2012
    Location
    USA
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    351

    Transfer cell values to another sheet, but need to skip duplicates

    Hi all,

    I need to create a macro that will transfer cell values to a new sheet, but I need it to skip duplicate values and move on to the next cell, and end sub on the first blank value. All of my duplicates will be grouped together. Column B will look something like:

    1100079878
    1100079878
    1100895461
    1112548741
    1112548741

    So on my new sheet I just need 1100079787, 1100895461, and 1112548741 because the others are duplicates. I would think this would be some kind of an If Then statement combined with a loop, but I'm not sure where to start. Any advice for + rep?

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Transfer cell values to another sheet, but need to skip duplicates

    there are many modes to do, try this
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    07-26-2012
    Location
    USA
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    351

    Re: Transfer cell values to another sheet, but need to skip duplicates

    "Variable not defined" and it highlights LR

  4. #4
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Transfer cell values to another sheet, but need to skip duplicates

    I'm sorry, the right line is
    LR = Cells(Rows.Count, "B").End(xlUp).Row
    but look for possible type errors
    Last edited by patel45; 08-22-2012 at 01:36 AM.

  5. #5
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Transfer cell values to another sheet, but need to skip duplicates

    Hi, VBA FTW,

    if youīre using Option Explicit itīs mandatory to define each variable used.

    Please Login or Register  to view this content.
    Ciao,
    Holger

  6. #6
    Forum Contributor
    Join Date
    07-26-2012
    Location
    USA
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    351

    Re: Transfer cell values to another sheet, but need to skip duplicates

    Hey thanks for your help, and sorry for the delayed response, I think we're almost there. Here's the code:
    Please Login or Register  to view this content.
    And here's what I'm getting:
    12345 12345
    12345 12345
    125565 125565
    189878 189878
    787478 787478
    58698 58698
    58698
    12345

    The first column are my actual numbers from my original sheet. The 2nd column is my results. The macro left out the last 2 duplicates, but not the first one. Any thoughts? After I get this straightened out I'm going to need to figure out how to transpose these numbers onto the same row, but first things first

    ---------- Post added at 02:25 PM ---------- Previous post was at 02:18 PM ----------

    I just changed my range from B9 to B8, and it gets rid of the first duplicate (above post), but it is taking what's in B8 and putting on my sheet. B8 says "Invoice Number" so I need a work around for this

  7. #7
    Forum Contributor
    Join Date
    07-26-2012
    Location
    USA
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    351

    Re: Transfer cell values to another sheet, but need to skip duplicates

    Actually, I can just re-organize sheet2 so having my range as B8 will be fine. However, is there any way to transpose this data and get it to A16:H16 instead of J17:J22?

  8. #8
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Transfer cell values to another sheet, but need to skip duplicates

    Hi, VBA FTW,

    regarding your information about the duplicates: youīre sure thereīs a heading above the raneg you check for duplicates? If not, the first item in thst range is considered to be the heading - no duplicate for the heading.

    Regarding transposing: I pretty much doubt that functionality (Iīm not that much famliar with the Advanced Fiter to tell if itīs possible or not). Best way might be to read the values into an array and use that for output (and again: I donīt know if itīs possible).

    Afraid to not really have offered any real help for this topic.

    Ciao,
    Holger

  9. #9
    Forum Contributor
    Join Date
    07-26-2012
    Location
    USA
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    351

    Re: Transfer cell values to another sheet, but need to skip duplicates

    Holger, thanks for the response. I'll have to read up on arrays as I don't have any experience using it. Your input is appreciated, the more I hear, the more I learn. I'm going to do some research and see if I can work something out.

  10. #10
    Forum Contributor
    Join Date
    07-26-2012
    Location
    USA
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    351

    Re: Transfer cell values to another sheet, but need to skip duplicates

    Well, I've figured it out. Not the slickest code, but it accomplishes what I need it to so I'm satisfied. Thanks for the input guys. I've attached a file that has the code if anyone wants to look at it. Thanks again
    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)

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