Macros

T

TX_AGS

I would like to create a macro that copies and pastes data from 1 worksheet
to another, but each time it is run it records the data in a new row. Any
help appreciated.
 
M

Mike H

Given that you haven't over-explained your question here's a solution you may
be able to build on. It's worksheet code and goes in the sheet you want to
copy the data from

Sub stance()
Dim MyRange As Range
Dim CopyRange As Range
lastrow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
Set MyRange = Range("A1:A" & lastrow)
For Each C In MyRange
If UCase(C.Value) = "SOMEVALUE" Then
If CopyRange Is Nothing Then
Set CopyRange = C.EntireRow
Else
Set CopyRange = Union(CopyRange, C.EntireRow)
End If
End If
Next
If Not CopyRange Is Nothing Then
lastrow = Sheets("Sheet2").Cells(Cells.Rows.Count, "A").End(xlUp).Row
CopyRange.Copy Sheets("Sheet2").Range("A" & lastrow + 1)
End If

End Sub

Mike
 
G

Gary''s Student

The following macro will copy the first row of the source sheet to the next
available row of the destination sheet:

Sub ags()
Dim ss As Worksheet, sd As Worksheet
Set ss = Sheets("source")
Set sd = Sheets("destination")
n = sd.Cells(Rows.Count, "A").End(xlUp).Row + 1
ss.Range("1:1").Copy Destination:=sd.Range("A" & n)
End Sub
 
S

Sheeloo

Try
Sub copy1()
Dim lastRow As Long
lastRow = Worksheets("Sheet2").Cells(Worksheets("Sheet2").Rows.Count,
"A").End(xlUp).Row
Worksheets("Sheet1").UsedRange.Copy
Worksheets("Sheet2").Activate
Range("A" & (lastRow + 1)).Select
ActiveSheet.Paste
End Sub
 
Top