Sub search1() Dim i As Integer Dim MaVariable1 As String MaVariable1 = "S30.G01.00.001" ' Boucle de recherche par ligne sur la colonne A For i = 1 To 537 With Worksheets(1) If .Cells(i, 1).Value = MaVariable1 Then .Rows(i).Copy Sheets(2).Rows("1").Insert Shift:=xlDown 'Insertion de la selection copier End If End With Next i End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionSub test() Workbooks.OpenText Filename:= _ "D:\Users\ysebbarh.EMEA\Desktop\test_macro\RAF1.txt" Workbooks.OpenText Filename:= _ "D:\Users\ysebbarh.EMEA\Desktop\test_macro\NIR1.txt" Columns("A:A").Select Selection.NumberFormat = "0" Sheets.Add ActiveSheet.Name = "Resultat" i = 1 For j = 2 To 16 valeur = Workbooks("NIR1.txt").Sheets("NIR1").Cells(j, 1) Workbooks("RAF1.txt").Activate Set celluletrouvee = Range("A:A").Find(valeur) ligne = celluletrouvee.Row Do Workbooks("NIR1.txt").Sheets("Resultat").Cells(i, 1) = Workbooks("RAF1.txt").Sheets("RAF1").Cells(ligne, 1) i = i + 1 ligne = ligne + 1 Loop Until (Left(Workbooks("RAF1.txt").Sheets("RAF1").Cells(ligne, 1), 14)) = "S30.G01.00.001" Next End End Sub