Coding Help: Copy Checked Rows to Another Sheet

G

Guest

Dear Excel 2003 Users,

Has anyone ever done the following:

On a worksheet, have a series of rows, where there is a place in
Column A to place a checkmark.

The user would go through and check the rows that are needed to create
a "client to-do checklist".

Somewhere on the sheet, there would be a button that would copy only
the lines that are checked and either put them on a new worksheet or
into a new workbook. If it is easier to delete the unchecked rows,
that would also be great, I would base the initial document on a
template to keep it intact.

It would be greatly appreciated if anyone can share some code to
accomplish this. Thanks a million in advance!

Kevin
 
J

Jason

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.
 
Top