Solved

# copy and paste rows from one sheet to another(Excel)

Posted on 2013-06-17
468 Views
Hi ,

I am looking for a MACRO to copy data from "sheet1" to the next available row on "sheet2".

excel sample attached.

Thanks very much
Book1.xlsm
0
Question by:shamilaz
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 2
• 2

LVL 43

Expert Comment

ID: 39254752
Uncomment one of the commented rows.
The first one will copy only row 3.
The second one will copy row 3 down to the last available rows.

``````Sub copyrows()
Dim sws As Worksheet
Dim tws As Worksheet
Set sws = Sheets("sheet1")
Set tws = Sheets("sheet2")
'sws.Range("A3").EntireRow.Copy tws.Range("A" & Rows.Count).End(xlUp).Offset(1)
'sws.Range("A3:A" & sws.Range("A" & Rows.Count).End(xlUp).Row).EntireRow.Copy tws.Range("A" & Rows.Count).End(xlUp).Offset(1)
End Sub
``````
0

Author Comment

ID: 39254925
Sorry forgot to mention one more thing....the copy and paste should be as a "value" only.....so that any links and formulas from the source doc will be disabled after the paste.  Appreciate if you could kindly amend to reflect this please
0

LVL 43

Accepted Solution

Saqib Husain, Syed earned 500 total points
ID: 39255198
Sub copyrows()
Dim sws As Worksheet
Dim tws As Worksheet
Dim sr As Range
Set sws = Sheets("sheet1")
Set tws = Sheets("sheet2")
Set sr = sws.Range("A3:A" & sws.Range("A" & Rows.Count).End(xlUp).Row)
If sws.Range("A3") <> "" Then
tws.Range("A" & Rows.Count).End(xlUp).Offset(1).Resize( _
sr.Rows.Count).EntireRow.Value = sr.EntireRow.Value
End If
End Sub
0

Author Closing Comment

ID: 39255273
Perfect ...the macro works as expected...great....thanks very much :-)
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filledā¦
###### Suggested Courses
Course of the Month7 days, 16 hours left to enroll