1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| Sub Import()
Dim strLigne As String, Str() As String, Y As String
Dim n As Integer
Dim i As Long
Open "C:\Users\user\Desktop\exemple.txt" For Input As #1
With Worksheets("Feuil1") 'à adapter
Do While Not EOF(1)
Line Input #1, strLigne
Str = Split(strLigne, ",")
n = UBound(Str)
If n > 0 Then
i = i + 1
.Range("A" & i).Value = Str(0)
Y = Str(1)
If n > 1 Then Y = Y & "." & Str(2)
.Range("B" & i).Value = Val(Y)
End If
Loop
Close #1
'trier sur la colonne A
.Range("A1:B" & i).Sort key1:=.Range("A1"), Order1:=xlDescending, Header:=xlNo
End With
End Sub |
Partager