Consulting

Results 1 to 6 of 6

Thread: Import, Skip Duplicate Records

  1. #1

    Import, Skip Duplicate Records

    This sheet import a file.
    In column G are the unique value
    my problem, during the import file, skip the rekord if this is already imported
    (for example if i impot the same file twice)
    Sal
    1 help 1 pizza
    2 help 1 pizza 1 caff?
    3 help 1 pizza 1 caff? 1 mozzarella
    ...
    Spaghetti, Lasagne and Tortellini for the "Lady" ;-)

  2. #2
    VBAX Regular
    Joined
    Jun 2004
    Location
    Cordova, Alaska
    Posts
    10
    Location
    Hi Sal,



    Here's a routine that should delete the entire row(s) of any exact duplicates within the used range. It won't prevent the data from being imported twice, but should clean it up after the fact if it happens.

    Sub DeleteDuplicateRows()
    Dim iRow As Long
    Dim jRow As Long
    Dim iCol As Integer
    Dim LastRow As Long
    Dim FirstRow As Long
    Dim FirstCol As Integer
    Dim LastCol As Integer
    Dim DelCount As Long
    Dim DupFound As Boolean
    DelCount = 0
    Range("B11").CurrentRegion.Select '(Selects the range)
    FirstRow = Selection.Row
    LastRow = FirstRow + Selection.Rows.Count - 1
    FirstCol = Selection.Column
    LastCol = FirstCol + Selection.Columns.Count - 1
    For iRow = FirstRow To LastRow - 1
    For jRow = iRow + 1 To LastRow
    DupFound = True
    For iCol = FirstCol To LastCol
    DupFound = DupFound And (Cells(jRow, iCol) = Cells(iRow, iCol))
    If Not DupFound Then Exit For
    Next iCol
    If DupFound Then
    Rows(jRow).Delete
    LastRow = LastRow - 1
    DelCount = DelCount + 1
    End If
    Next jRow
    Next iRow
    [A1].Select
    End Sub
    
    Just change the reference from B11 to the Top / Left cell of you range of interest.

    Hope it helps,

    Dan


  3. #3
    Site Admin
    The Princess
    VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location
    Sal
    1 help 1 pizza
    2 help 1 pizza 1 caff?
    3 help 1 pizza 1 caff? 1 mozzarella
    Forget it, Sal. I want the pasta!!
    How do I get the spaghetti!!??
    ~Anne Troy

  4. #4
    Ok! ... for the spaghetti, i adjust my signature...
    Sal
    1 help 1 pizza
    2 help 1 pizza 1 caff?
    3 help 1 pizza 1 caff? 1 mozzarella
    ...
    Spaghetti, Lasagne and Tortellini for the "Lady" ;-)

  5. #5
    Site Admin
    The Princess VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location
    LOL!! Yes. Spaghetti will be safer now, I think. I tell you, I ate pizza, and it is true--not a joke! Hee hee.
    ~Anne Troy

  6. #6
    Tks HalfAce, but for me is important during the import of file....
    Sal
    1 help 1 pizza
    2 help 1 pizza 1 caff?
    3 help 1 pizza 1 caff? 1 mozzarella
    ...
    Spaghetti, Lasagne and Tortellini for the "Lady" ;-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •