View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
ATOMICLUIS ATOMICLUIS is offline
external usenet poster
 
Posts: 1
Default Help with copying selected row to new sheet


With the code below I have the following problem. Please help

If the source sheet contains data on B2:B5, and "X"s on A2:A5.
Data on B2:B5 should get copied since they all have an "X" on column A.

But after running the macro only the data from B5 get copied.

Now, If I also include data on C2:C5, then everything get copied.

thanks.

This is what i am using:

Sub Priority()
Application.ScreenUpdating = False
Worksheets("Sheet2").Select
For Each r In Worksheets("Sheet2").UsedRange.Rows
n = r.Row
If Worksheets("Sheet2").Cells(n, 1) = "X" Then
Worksheets("Sheet2").Range(Cells(n, 2), Cells(n, 7)).Copy _
Destination:=Worksheets("Sheet1").Range("B65536"). End(xlUp).Offset(1,
-1)
Else
End If
Next r

Worksheets("Sheet2").Columns("A").Replace What:="X", Replacement:="*",
_
SearchOrder:=xlByColumns, MatchCase:=True

Application.CutCopyMode = True
Application.ScreenUpdating = True

End Sub


--
ATOMICLUIS
------------------------------------------------------------------------
ATOMICLUIS's Profile: http://www.excelforum.com/member.php...o&userid=28773
View this thread: http://www.excelforum.com/showthread...hreadid=484721