Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / December 2005

Tip: Looking for answers? Try searching our database.

Coding Help: Copy Checked Rows to Another Sheet

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
No Spam - 12 Dec 2005 21:54 GMT
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
Jason - 13 Dec 2005 15:05 GMT
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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.