Récupération ligne dans excel

scoobydoos Messages postés 64 Date d'inscription vendredi 31 mai 2002 Statut Membre Dernière intervention 28 novembre 2010 - 19 nov. 2004 à 09:35
 Utilisateur anonyme - 19 nov. 2004 à 09:59
Salut,
Voila G un fichier tarif.txt composé comme suit :
Ref Designation Prix HT Prix TTC
00010 BIC 0.217 0.259
Ect...
Je souhaite avec une fichier excel faire une recherche de ref et mettre la ligne correspondante dans excel (tableau commande).
Merci par avance pour vos réponses
@+

1 réponse

Utilisateur anonyme
19 nov. 2004 à 09:59
Salut,
Déjà il faut trier la ligne texte et séparer les différentes données:
Si tu as toujours des espaces entre les données

Private Sub Command1_Click()

Dim Ligne, Ch, Ref, Des, PHT, TTC As String
Ligne = "00010 BIC 0.217 0.259"
Ref = ""
For rt = 1 To Len(Ligne)
Ch = Mid(Ligne, rt, 1)
If Ch = " " Then
Exit For
Else
Ref = Ref & Ch
End If
Next rt

Des = ""
For rta = (rt + 1) To Len(Ligne)
Ch = Mid(Ligne, rta, 1)
If Ch = " " Then
Exit For
Else
Des = Des & Ch
End If
Next rta

PHT = ""
For rtb = (rta + 1) To Len(Ligne)
Ch = Mid(Ligne, rtb, 1)
If Ch = " " Then
Exit For
Else
PHT = PHT & Ch
End If
Next rtb
TTC = Right(Ligne, (Len(Ligne) - rtb))
List1.Clear
List1.AddItem Ref
List1.AddItem Des
List1.AddItem PHT
List1.AddItem TTC

End Sub

A+

A.C.I.V.E SARL
Automatismes Conception Informatique Vidéo Electronique
0
Rejoignez-nous