+ Reply to Thread
Results 1 to 6 of 6

Problem with deleting duplicates

  1. #1
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Problem with deleting duplicates

    Hi,
    I have been trying to delete rows based on 4 columns criteria.
    Unfortunately i cannot use the auto filter method without upsetting the order of the data.
    I am pulling data from a number of workbooks each week. Then i need to deal with any duplicated rows.
    Columns to check are
    E name ie Sean Thomas
    J Claim number ie 00884565 or 006734561/1 or 12345672 or similar
    K Registration ie ABC123Z
    U Cost ie £1234.50

    range of data A7:U & lastrow

    Checking the last row first to 7
    if E ,J,K are the same then check U (cost)
    if its the same as one above then delete it
    if its more or less than the one above, then delete the one above.

    I have tried deleting row based on criteria but this leaves a few duplicates still
    if i use the below code and change colour only, it works, but when i run the delete code it doesnt.

    the only way it seems to work is when i run the same code in concession.

    I cant for the life of me see what i am doing wrong.
    Sorry i cant upload data due to confidential data.

    any suggestions please?


    Please Login or Register  to view this content.
    Regards
    Sean

    Please add to my reputation if you think i helped
    (click on the star below the post)
    Mark threads as "Solved" if you have your answer
    (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code:
    [code] Your code here [code]
    Please supply a workbook containing example Data:
    It makes its easier to answer your problem & saves time!

  2. #2
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Problem with deleting duplicates

    Look at these lines
    Please Login or Register  to view this content.
    Sheets("Engineers Savings") and Sheet1 the same?
    try so
    Please Login or Register  to view this content.
    And also declare variables as
    Please Login or Register  to view this content.

  3. #3
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: Problem with deleting duplicates

    hi, thanks for the advise.
    found the error , needed to add an exit for when deleting the current row.

    Now this is the weird bit i cannot understand!
    I was originally running the code from within a userform (Progress indicator)
    everything else works fine, however when i run this code within the userform module it doesnt delete all duplicates.
    However if i run the code from a standard module on the same data it works fine.
    if i call the same procedure in the std module from within the userform it doesnt work properly.
    if i call it directly after unloading userform it works fine.

    any ideas?


    Please Login or Register  to view this content.
    Unable to load file as too large, cant reduce the size as mainly due to uerform which holds the code.

  4. #4
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: Problem with deleting duplicates

    For some reason my last post did not appear on latest threads.
    lets try again.

  5. #5
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: Problem with deleting duplicates

    Added file just in case. Managed to delete a load of stuff to reduce size
    Attached Files Attached Files

  6. #6
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: Problem with deleting duplicates

    I seem to have resolved the issue.
    I have used a progress indicator and have the code to import the other workbook data in that module.
    I then unload that form and open another progress indicator that hold the code to delete duplicate rows, blank rows and format the font etc.
    Really strange, i havent actually changed any of the code, only split it into 2 forms and it works.

    Is there only a certain amount of code you can put into a userform module?
    Attached Files Attached Files

  7. #7
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Problem with deleting duplicates

    This may not helpful, or relevant, but I though you want to shift A-U, not delete the entire row which your code is right now doing

+ 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