I'm no vba expert, but this should work:
--------------------------------------------------------
Sub CopyRows()
Dim X, Y
X = 1
For Y = 1 To 50
If Range("A" & Y).Value = "X" Then
Range("A" & Y).EntireRow.Copy
Sheets("Sheet2").Select
Range("A" & X).Select
ActiveSheet.Paste
X = X + 1
Sheets("Sheet1").Select
End If
Next Y
End Sub
------------------------------------------------------------
This will just copy the rows (from 1 to 50) that have an "X" in column
A on Sheet1. However, if you run it a second time, it won't delete the
rows that were copied the first time. So, if you copy 10 rows the
first time and five rows the second, you'll still see ten rows of data.
One other thing, for some reason, this code doesn't work if you put it
in the button. You'll have to write this in a module and run that from
the button.
Hopefully, this makes sense and is what you were looking for.
|