Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I'm trying to write a macro that copies data from one sheet to another, but i need it to append to row under the last row. E.g. If i have a sheet with 10 rows filled with data, i want the next time i want to append data in the sheet to start at the 11th row |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
try something like this
range("a1").end(xldown).offset(1,0) it will go the last row plus one row. -------------------------------- Todd wrote in message ... Hi, I'm trying to write a macro that copies data from one sheet to another, but i need it to append to row under the last row. E.g. If i have a sheet with 10 rows filled with data, i want the next time i want to append data in the sheet to start at the 11th row |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
To use the macro below, you first need to have the cells you want to "copy"
selected. Then run the macro. In the macro, you also need to define the "target_book" and "target_sheet". These are the file name of the target workbook and name of the target worksheet to which you want to send the data. Sub copy_data() Dim target_book As String Dim target_sheet As String 'define the sheet to which you want to send data target_book = "Book2.xls" target_sheet = "Sheet2" On Error GoTo copy_err With Workbooks(target_book).Worksheets(target_sheet).Ra nge("A1").CurrentRegion If .Rows.Count = 1 And .Cells(1).Formula = "" Then Selection.Copy .Range("A1") Else Selection.Copy .Range("A1").Offset(.Rows.Count, 0) End If End With Exit Sub copy_err: MsgBox ("Error copying to the target location."), vbExclamation End Sub Regards, Edwin Tam http://www.vonixx.com "Todd" wrote: Hi, I'm trying to write a macro that copies data from one sheet to another, but i need it to append to row under the last row. E.g. If i have a sheet with 10 rows filled with data, i want the next time i want to append data in the sheet to start at the 11th row |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I append data to an Excel workbook using a template? | Excel Discussion (Misc queries) | |||
Append instead of Replace in Merge Workbook? | Excel Worksheet Functions | |||
Append workbook into a "Master" workbook | Excel Discussion (Misc queries) | |||
Append data to a separate workbook | Excel Programming | |||
Append data | Excel Programming |