Attribute VB_Name = "ConvertTarif"
' les clients sont derriere ! et avant :
' les articles sont entre deux : et comportent 12 caracteres
' les désignations sont entre deux :
' les prix entre : et !
'https://forum.excel-pratique.com/excel/fichier-txt-en-excel-184732
Sub loadTarifs()
Dim sLine As String
Dim sepLIne As String
Dim numLine As Long
Dim sWord As String
  Dim sArr() As String
sWord = " D E S I G N A T I O N"
numLine = 1
'RepeatedCharacter(" ", 9) +
sepLIne = RepeatedCharacter("-", 112)
Open "f:\_pdf\vba\tarifs2021.txt" For Input As #1
Open "f:\_pdf\vba\tarifs_2021.txt" For Output As #2

While Not EOF(1)
Do
  Line Input #1, sLine
  iCnt = 0
   
  If InStr(1, sLine, ":") Then
  ReDim sArr(0)
   sArr = Split(sLine, ":")
   For i = LBound(sArr) To UBound(sArr)
     sArr(i) = VBA.Trim(sArr(i))  'Replace(sArr(i), " ", "")
   Next
   iCnt = 0
   For i = LBound(sArr) To UBound(sArr)
   If sArr(i) <> "" And sArr(i) <> "!" Then iCnt = iCnt + 1
   Next
   
  If InStr(1, sLine, ":0") Then
    Exit Do
  End If
  End If
  If iCnt >= 3 Then
    Print #2, sArr(0) & ";" & sArr(1) & ";" & sArr(2) & ";" & sArr(3)
  End If
  numLine = numLine + 1
Loop Until sLine = sepLIne Or EOF(1)
'Loop Until sLine = sepLIne Or sLine = "" Or EOF(1)
Wend
Close #1
Close #2
End Sub

Function RepeatedCharacter(ch As String, n_ch As Integer) As String
Dim s As String
Dim cnt
s = ch
cnt = 1
While cnt <> n_ch
  s = s & ch
  cnt = cnt + 1
Wend
RepeatedCharacter = s
End Function

