Copy row from one table to another

J

John

I'm trying to copy a row from Sheet1 TableA and insert it as the first row in
Sheet2 TableB (pushing existing TableB rows down). The following coder seems
to only copy the first cell into all the row cells.
Worksheets("Sheet1").Range("TableA")(i).Copy
Worksheets(P("Sheet2").Range("TableB").Insert Shift:=xlDown
where TableX is a named 2-dim array range of all data rows & cols in the
table.

What must I change to copy the entire row?

Thx for your help, John
 
B

Billy Liddel

Not checked but try;
change Worksheets("Sheet1").Range("TableA")(i).Copy

to Worksheets("Sheet1").Range("TableA")(i).entirerow.Copy

Peter
 
J

John

Billy, this copies the entire row of the sheet, I only want to copy the
entire row of the table. The updated sequence
Worksheets("Sheet1").Range("TableA")(i).entirerow.Copy
Worksheets("("Sheet2").Range("TableB").Insert Shift:=xlDown
results in a 1004 error copy area & paste ared not same.

How do I just copy the full row of TableA, not the full row of the sheet?

Thx so much for your help, John
 
B

Billy Liddel

I wrote this and it worked for one row; it copies to the bottom of tableB on
sheet 2


Sub copyTableRow()
Dim rng1 As Range
Dim rng2 As Range
Dim i As Long
Dim nr As Long
Dim iNCols

Set rng1 = Range("TableA")
Set rng2 = Range("TableB")

i = 6
nr = rng2.Rows.Count + 1
iNCols = rng1.Columns.Count

Worksheets("Sheet1").Range(Cells(i, 1), Cells(i, iNCols)).Copy _
Destination:=Sheets("sheet2").Range("A" & nr)
Application.CutCopyMode = False

End Sub

Hope this helps

Peter
 

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