Chercher mot dans fichier txt

Une difficulté, une précision posez vos questions

Modérateur : WIN32-[GG]

Répondre
deltin3
Batcheur occasionnel
Messages : 2
Enregistré le : 19 janv. 2010 12:34

Chercher mot dans fichier txt

Message par deltin3 »

Je cherche un batch pour chercher tous les mots commencant par "IGA" et "ZD0" dans un fichier texte et copier tous ces mots dans un autre fichier texte en leur rajoutant L1 pour IGA et L3 pour ZD0

Ex :

S'il trouve IGA014 il doit me donner IGA014L1
S'il trouve ZD0014 il doit me donner ZD0014L3

je suis débutant si quelqu'un pouvait m'aider.
deltin3
Batcheur occasionnel
Messages : 2
Enregistré le : 19 janv. 2010 12:34

Re: Chercher mot dans fichier txt

Message par deltin3 »

j'ai fait ca mais il me cherche que sur la colonne D les mots commencants par "IGA0"
il faudrait un 2eme argument au LIKE et étendre à toutes les colonnes de la feuille

Sub search()

Dim DestSheet As Worksheet
Set DestSheet = Worksheets("Sheet2")

Dim sRow As Long 'row index on source worksheet
Dim dRow As Long 'row index on destination worksheet
Dim sCount As Long
sCount = 0
dRow = 0

For sRow = 1 To Range("A65536").End(xlUp).Row
'use pattern matching to find "iga0" anywhere in cell
If Cells(sRow, "A") Like "IGA0*" Then
sCount = sCount + 1
dRow = dRow + 1
'copy cols D
Cells(sRow, "A").Copy Destination:=DestSheet.Cells(dRow, "A")
End If
Next sRow

MsgBox sCount & " rows copied", vbInformation, "Transfer Done"

End Sub
Répondre