Copy Entire Row

S

scottnshelly

I need a line of code to copy an entire active row. I have a loop to
find cells in A:A that meet a certain criteria. If that is met, I want
to copy the entire active row to paste onto a different sheet.

Thanks.
 
S

Simon Lloyd

Try using this, add a command button or autoshape button to run th
code

Regards,
Simon

Dim mycell
Dim rng As Range
t1 = InputBox("Enter the match you want", "What to look for?", "")
Set rng = Range("A:A")
For Each mycell In rng
If mycell.Value = t1 Then
mycell.Rows.Select
Selection.Copy
Sheets("Sheet2").Select
Set rng = Worksheets("Sheet2").Cells(Rows.Count, 1).End(xlUp)(2)
rng.Select
ActiveSheet.Paste
End If
Next
End Su
 
S

scottnshelly

Thanks guys,
Tom: I figured it'd be something simple like that. Thanks.

Simon: Nothing happens after I push Enter on the input box.

Thanks again
 
S

Simon Lloyd

Scott, if you have data in column A when you run the code the Inputbo
appears enter the word or text your looking for in the box then clic
ok, the code should then pick out your row with that criteria in colum
A and paste the entire row on to sheet2 in the next available row, o
course it wont work if you havent got a sheet2 so you need to chang
the name you can run this code for any active sheet and it will past
the result in Sheet2 or whatever you change that to!

Regards,
Simon
P.s the posted code worked fine for m
 

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

Top