Loop - finding X in column n cpyin/pastin row

December 7, 2011 at 10:26:58
Specs: Windows XP
How do I create a macro that loops through each cell in Column A to check for an "x" or whatever and when it finds one, it copies the values in that row over and pastes it in another sheet for trending purposes. After copying a row, it continues it's loop.

See More: Loop - finding X in column n cpyin/pastin row

Report •

December 7, 2011 at 10:27:56
If it's easier, let me know and I can send you the test file. Thanks in advance to anyone who can help me with this!

Report •

December 7, 2011 at 15:54:58
Sub CopyX()
'Determine last Row with data in Sheet1
 last1Rw = Sheets(1).Range("A" & Rows.Count).End(xlUp).Row
'Loop through Column A
  For nxtCell = 1 To last1Rw
'If cell contains an x, find last row in
'Sheet2 and copy Row
   If Sheets(1).Range("A" & nxtCell) = "x" Then
     last2Rw = Sheets(2).Range("A" & Rows.Count).End(xlUp).Row
       Sheets(1).Range("A" & nxtCell).EntireRow.Copy _
          Destination:=Sheets(2).Range("A" & last2Rw + 1)
   End If
End Sub

Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.

Report •
Related Solutions

Ask Question