Hi! Thank you for your answer. But I get the following error :
Erreur 9 : l'indice n'appartient pas à la sélection. I can't figure out how to translate it but here is the MS page : http://support.microsoft.com/kb/468889/fr Any idea what to do...? Souriane On 1 mai, 13:34, Roger Govier <rogergov...@googlemail.com> wrote: > Hi > > Try the following code. > It assumes that column A has the maximum number of entries, to determine how > many rows to loop through. > If that is not the case, change the column letter from "A" to wahtever you > wsih. > > Sub CopyLines() > > Dim wsS As Worksheet, wsD As Worksheet > Dim lr As Long, i As Long, j As Long > Set wsS = ThisWorkbook.Sheets("Sheet1") ' Source > Set wsD = ThisWorkbook.Sheets("Sheet2") ' Destination > lr = wsS.Cells(Rows.Count, "A").End(xlUp).Row > j = 1 > For i = 1 To lr > If wsS.Cells(i, 5) = 1 Then > wsS.Rows(i).Copy wsD.Rows(j) > j = j + 1 > End If > Next i > > End Sub > > Roger Govier > Microsoft Excel MVP > > 2009/5/1 Souriane <jsouri...@videotron.ca> > > > > > > > > > Hi, > > > I would like to build a macro that does the following: > > > I am in Sheet 1. > > If the cell of "Column E" = "1" > > Then copy the entire ligne. > > Select Sheet 2 > > Paste the whole line > > Select Sheet 1 > > Repeat as long as there is a "1" in column E. > > > At the beginning of the macro, Sheet 2 is entirely empty. > > > Thank you in advance for you help! > > > Souriane > > -I am in the process of learning...! > > -- > Roger Govier > rogergov...@gmail.com- Masquer le texte des messages précédents - > > - Afficher le texte des messages précédents - --~--~---------~--~----~------------~-------~--~----~ ------------------------------------------------------------------------------------- Some important links for excel users: 1. Excel and VBA Tutorials(Video and Text), Free add-ins downloads at http://www.excelitems.com 2. Excel tutorials at http://www.excel-macros.blogspot.com 3. Learn VBA Macros at http://www.vbamacros.blogspot.com 4. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com If you find any spam message in the group, please send an email to: Ayush Jain @ jainayus...@gmail.com or Ashish Jain @ 26may.1...@gmail.com ------------------------------------------------------------------------------------- -~----------~----~----~----~------~----~------~--~---