Sub LeggiMetel()
'On Local Error Resume Next
On Error GoTo errore
Dim InputData As String
Dim Articolo As String
Dim EAN13 As String
Dim Descrizione As String
Dim Prezzo As Variant
Dim Molt As String
Dim UM As String
Dim DATA As String
Dim I As Integer
Application.ScreenUpdating = False
I = 4
'MsgBox ThisWorkbook.Path
Dim r As Range
Sheets(1).Range("A" & CStr(I) & ":IV65536").Clear
'Open "c:FINLSP 01-05-11.TXT" For Input As #1
Open ThisWorkbook.Path & "FINLSP 01-05-11.TXT" For Input As #1
Do While Not EOF(1)
Line Input #1, InputData
Articolo = Trim(Mid$(InputData, 1, 19))
EAN13 = Trim(Mid$(InputData, 20, 13))
Descrizione = Trim(Mid$(InputData, 33, 43))
Prezzo = Val(Trim(Mid$(InputData, 109, 11.2))) / 100
Molt = Trim(Mid$(InputData, 120, 6))
UM = Trim(Mid$(InputData, 129, 3))
DATA = Trim(Mid$(InputData, 134, 8))
If I > 1 Then
With Sheets(1)
.Range("A" + CStr(I)).Value = Articolo
.Range("B" + CStr(I)).Value = EAN13
.Range("C" + CStr(I)).Value = Descrizione
.Range("D" + CStr(I)).Value = Prezzo
.Range("E" + CStr(I)).Value = Molt
.Range("F" + CStr(I)).Value = UM
.Range("G" + CStr(I)).Value = DATA
End With
End If
I = I + 1
Loop
Close #1
Application.ScreenUpdating = True
Exit Sub
errore:
Close #1
MsgBox "Errore " & Err.Description
End Sub |