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

    iMPORT TXT... (2000 sr-1)

    Edited by HansV - please don't use the Script font for VBA code - it's hard to read!

    ... ACCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
    Why the macro not get the value for var:AG, CC and TITOLARE?????

    attached file:http://www.mytempdir.com/741190
    <pre>Sub TAB_TI001D()
    Dim RIGA As String
    Set ELENCO = Worksheets("TI001D")
    ELENCO.Range("A3:L65536").ClearContents

    RIGA = 3
    'Call Chop132

    iFile = FreeFile()

    NomeFile = "C:EPFTI001D_132.EPF"

    'Ciclo apertura file di testo
    Open NomeFile For Input As #iFile

    Do Until EOF(iFile)

    Line Input #iFile, Record_Corrente

    If Mid(Record_Corrente, 1, 10) = "DIPENDENZA" Then
    DIPENDENZA = Trim(Mid(Record_Corrente, 22, 4))
    End If
    If Mid(Record_Corrente, 28, 12) = "ANNULLAMENTO" Then
    CTR_TIT = Trim(Mid(Record_Corrente, 52, 10)) & "/" & Trim(Mid(Record_Corrente, 63, 5))
    NOMINATIVO = Trim(Mid(Record_Corrente, 76, 39))
    NDG = Trim(Mid(Record_Corrente, 118, 14))
    MATR = Trim(Mid(Record_Corrente, 19, 7))

    If Mid(Record_Corrente, 28, 15) = "C/C REGOLAMENTO" Then
    AG = Trim(Mid(Record_Corrente, 49, 4))
    CC = Trim(Mid(Record_Corrente, 53, 8))


    If Mid(Record_Corrente, 34, 42) = "TITOLARE" Then
    TITOLARE = Mid(Record_Corrente, 49, 50) ' * 1
    End If

    End If

    'Scrittura record su elenco
    ELENCO.Range("A" + RIGA).Value = DIPENDENZA
    ELENCO.Range("B" + RIGA).Value = CTR_TIT
    ELENCO.Range("C" + RIGA).Value = NOMINATIVO
    ELENCO.Range("D" + RIGA).Value = NDG
    ELENCO.Range("E" + RIGA).Value = MATR
    ELENCO.Range("F" + RIGA).Value = AG
    ELENCO.Range("G" + RIGA).Value = CC
    ELENCO.Range("H" + RIGA).Value = TITOLARE
    'CONTATORE
    ELENCO.Range("B1").Value = RIGA - 2
    RIGA = RIGA + 1
    'CONTATORE

    End If
    Loop
    Close #iFile

    End Sub</pre>


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

    Re: iMPORT TXT... (2000 sr-1)

    AG and CC are only assigned values if Mid(Record_Corrente, 28, 15) = "C/C REGOLAMENTO". But this If ... End If part is nested within an If ... End If part with condition Mid(Record_Corrente, 28, 12) = "ANNULLAMENTO". So the inner condition will never be true.
    I suspect that you should place some End Ifs in a different place, but since I don't know exactly what you want, I can't suggest where.

Posting Permissions

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