#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Macros

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.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Macros

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

"TX_AGS" wrote:

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.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Macros

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

--
Gary''s Student - gsnu200810


"TX_AGS" wrote:

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.

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,805
Default Macros

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

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.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macros: can you copy macros from one doc to another? Roady Excel Discussion (Misc queries) 1 June 12th 08 05:47 PM
Excel 2007 macros - how to merge 5 macros together into one Sue Excel Discussion (Misc queries) 1 April 16th 08 08:36 PM
Macros warning always shows up, even if all macros removed Joe M Excel Discussion (Misc queries) 1 December 20th 07 04:45 AM
Macros - copying macros from one computer to another TT Excel Discussion (Misc queries) 18 December 14th 06 03:24 AM
Training: More on how to use macros in Excel: Recording Macros ToriT Excel Worksheet Functions 2 February 10th 06 07:05 PM


All times are GMT +1. The time now is 11:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"