Solved

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

Posted on 2013-06-17
4
460 Views
Last Modified: 2013-06-17
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
Comment
Question by:shamilaz
  • 2
  • 2
4 Comments
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
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

Open in new window

0
 

Author Comment

by:shamilaz
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

by:
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

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

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Article by: Leon
Software Metering within our group of companies has always been an afterthought until auditing of software and licensing became a pain point. Orchestrator and SCCM metering gave us the answer and it was an exciting process.
PaperPort has a feature called the "Send To Bar". It provides a convenient, drag-and-drop interface for using other installed software, such as Microsoft Office. However, this article shows that the latest Office 2016 apps (installed with an Office …
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now