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 <[email protected]>
>
> 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
[email protected]
--~--~---------~--~----~------------~-------~--~----~
-------------------------------------------------------------------------------------
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 [email protected]
If you find any spam message in the group, please send an email to:
Ayush Jain @ [email protected] or
Ashish Jain @ [email protected]
-------------------------------------------------------------------------------------
-~----------~----~----~----~------~----~------~--~---