Copy entire row if...

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need help copying entire row from "table1.xls" if column B is "text1" to
"table2.xls". what is the most simple way of doing this?

Thanks
 
If Cells(2,"B") = "text1" Then
Cells(2,"B").Entirerow.Copy
Destination:=Workbooks("table2.xls").Worksheets("Sheet1").Range("A1")
End If

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
Thanks Bob, that was very helpful. There is still one more detail I want to
solve. I want to be able to put more than one row in destination table, so
that the data is saved always to next empty row. Because of this I can't
order the certain range.
 
Sam,

Try something like


If Cells(2,"B") = "text1" Then
Set oWS = Workbooks("table2.xls").Worksheets("Sheet1")
cLastRow = oWS.Cells(Rows.Count,"A").End(xlUp).Row
Cells(2,"B").Entirerow.Copy
Destination:=.oWS.Cells(cLastRow+1,"A")
End If


--

HTH

RP
(remove nothere from the email address if mailing direct)
 
then change to this idea

With workbooks"table2.xls").worksheets("sheet1")
If Cells(2,"B") = "text1" Then
x = .Cells(Rows.Count, 1).End(xlUp).Row + 1
Cells(2, "b").EntireRow.Copy .Cells(x, 1)
End With
end if
End Sub

If Cells(2,"B") = "text1" Then
Cells(2,"B").Entirerow.Copy
Destination:=Workbooks("table2.xls").Worksheets("Sheet1").Range("A1")
End If
 

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