Results 1 to 5 of 5
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    skip record from import file (2000)

    controll and skip duplicate...

    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)

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: skip record from import file (2000)

    In the code behind the userform, replace the part

    If Max_10 >= 10 Then
    ...
    End If

    by

    If Max_10 >= 10 Then
    Dim ID As String
    Dim rngFind As Range
    ID = Mid(Elenco.Cells(Riga + 3, 1), 42, 6)
    Set rngFind = Range(Range("G3"), Range("G65536").End(xlUp)).Find(ID)
    If Not rngFind Is Nothing Then
    Range("F" & Riga2) = Mid(Elenco.Cells(Riga + 7, 1), 16, 2)
    Range("A" & Riga2) = Mid(Elenco.Cells(Riga - 2, 1), 14, 4)
    Range("B" & Riga2) = Left(Elenco.Cells(Riga + 3, 1), 6)
    Range("C" & Riga2) = Mid(Elenco.Cells(Riga - 2, 1), 31, 2)
    Range("D" & Riga2) = Left(Elenco.Cells(Riga + 5, 1), 25)
    Range("E" & Riga2) = Mid(Elenco.Cells(Riga + 3, 1), 25, 16) * 1
    Range("G" & Riga2) = ID
    Range("H" & Riga2) = Mid(Elenco.Cells(Riga + 3, 1), 51, 2)
    Range("I" & Riga2) = Mid(Elenco.Cells(Riga + 3, 1), 11, 10)
    Range("J" & Riga2) = Mid(Elenco.Cells(Riga + 3, 1), 56, 10)
    Range("K" & Riga2) = Mid(Elenco.Cells(Riga + 3, 1), 68, 4)
    Range("L" & Riga2) = Mid(Elenco.Cells(Riga + 3, 1), 74, 10)
    Range("M" & Riga2) = Mid(Elenco.Cells(Riga + 3, 1), 86, 5)
    Range("N" & Riga2) = Mid(Elenco.Cells(Riga + 3, 1), 99, 4)
    Range("O" & Riga2) = Mid(Elenco.Cells(Riga + 4, 1), 14, 3)
    Range("P" & Riga2) = Left(Elenco.Cells(Riga + 6, 1), 60)
    End If
    End If

    Notes:
    - Take care to find the End If belonging to If Max_10 >= 10 Then.
    - If you indented your code consistently, it would be much easier to read and modify it.
    - I think I mentioned this before, but you should have Option Explicit at the top of every module, and declare all variables explicitly.

  3. #3
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: skip record from import file (2000)

    AAAAAAAAAAAAAARRRRRRRRRRRRRRGGGGGGGGGGGG!!!
    HansV re attache my file with modfy.
    I have a prob
    With your modify when i import for the first one (with a cleared sheet), the macro import nothing record...

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: skip record from import file (2000)

    Here it is.

  5. #5
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: skip record from import file (2000)

    Natrurally... IT WORK.

Posting Permissions

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