Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 177
Default append data to other workbook

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default append data to other workbook

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default append data to other workbook

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
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
How do I append data to an Excel workbook using a template? Statman Excel Discussion (Misc queries) 2 May 31st 06 06:58 PM
Append instead of Replace in Merge Workbook? Ayako Utsumi Excel Worksheet Functions 0 November 18th 05 04:48 AM
Append workbook into a "Master" workbook Barb Reinhardt Excel Discussion (Misc queries) 10 September 20th 05 10:41 PM
Append data to a separate workbook hurlbut777 Excel Programming 0 April 27th 05 11:15 PM
Append data Dizzy[_3_] Excel Programming 1 January 30th 04 01:52 PM


All times are GMT +1. The time now is 12:41 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"