Finding, copying and pasting

  • Thread starter Thread starter kevwest
  • Start date Start date
K

kevwest

I want to get some code that will do a few functions for me. I have a
worksheet with 1000's of entries and I want to find and use only about
15 of them. I can find them by their name which is displayed in column
A, I then want to select the whole row and add it to a new worksheet.
I want to repeat this for the other 14 entries and add them to the
same new worksheet.

Any helpful thoughts?
 
Put the 15 entries from column A in a new worksheet. then write a macro tha
wil only move these rows. I didn't test the code below but will do the job
after it is debugged. It may even work first time. I wrote a lot of code
just like this in the past.

Sub move_data()

Workbooks.Add
Set newbk = ActiveWorkbook
NewbkRowcount = 1

With ThisWorkbook.Sheets("sheet2")
Sh2Rowcount = 1
Do While .Range("A" & Sh2Rowcount) <> ""
SearchName = .Range("A" & Sh2Rowcount)
With ThisWorkbook.Sheets("sheet1")
Sh1RowCount = 1
Do While .Range("A" & Sh1RowCount) <> ""
If SearchName = .Range("A" & Sh1RowCount) Then
.Rows(Sh1RowCount).Copy _
Destination:=newbk.Sheets("sheet1").Rows(NewbkRowcount)
NewbkRowcount = NewbkRowcount + 1
End If
Sh1RowCount = Sh1RowCount + 1
Loop
End With
Sh2Rowcount = Sh2Rowcount + 1
Loop
End With

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top