ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   append row (https://www.excelbanter.com/excel-programming/305410-append-row.html)

joe

append row
 
Hi,

can VBA be used to append rows of data from sheet2
from "day.xls" to the last row of the data in sheet1 of
the "hours.xls"?

many thanks.


regards,
Joe

Ron de Bruin

append row
 
Hi

Are both files open Joe or one of the two

--
Regards Ron de Bruin
http://www.rondebruin.nl


"Joe" wrote in message ...
Hi,

can VBA be used to append rows of data from sheet2
from "day.xls" to the last row of the data in sheet1 of
the "hours.xls"?

many thanks.


regards,
Joe




joe

append row
 
Hi,

I actually gt one file: name.xls that contains sheet1 and
sheet2 and i am using the button to generate a new file
call: Book1.xls, copy the data from sheet1 of the name.xls
and paste to sheet1 of the Book1.xls.This is followed by
copy and paste the data from sheet2 of the name.xls to
the last row of the data that has been pasted (data copy
and pasted to sheet1 of the Book1.xls).

regards,
Joe
-----Original Message-----
Hi

Are both files open Joe or one of the two

--
Regards Ron de Bruin
http://www.rondebruin.nl


"Joe" wrote in

message ...
Hi,

can VBA be used to append rows of data from sheet2
from "day.xls" to the last row of the data in sheet1 of
the "hours.xls"?

many thanks.


regards,
Joe



.


Ron de Bruin

append row
 
Hi Joe

If i understand you correct then this will work for you
You can use this two line if yoyu want to save the file and close it

'wb2.SaveAs "C:\test2.xls
'wb2.Close False


Sub test()
Dim wb1 As Workbook
Dim wb2 As Workbook
Set wb1 = ActiveWorkbook
Set wb2 = Workbooks.Add(1)

wb1.Sheets(1).UsedRange.Copy wb2.Sheets(1).Range("A1")

wb1.Sheets(2).UsedRange.Copy wb2.Sheets(1).Range("A" & _
wb2.Sheets(1).UsedRange.Rows.Count + 1)

'wb2.SaveAs "C:\test2.xls
'wb2.Close False

Set wb1 = Nothing
Set wb2 = Nothing
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Joe" wrote in message ...
Hi,

I actually gt one file: name.xls that contains sheet1 and
sheet2 and i am using the button to generate a new file
call: Book1.xls, copy the data from sheet1 of the name.xls
and paste to sheet1 of the Book1.xls.This is followed by
copy and paste the data from sheet2 of the name.xls to
the last row of the data that has been pasted (data copy
and pasted to sheet1 of the Book1.xls).

regards,
Joe
-----Original Message-----
Hi

Are both files open Joe or one of the two

--
Regards Ron de Bruin
http://www.rondebruin.nl


"Joe" wrote in

message ...
Hi,

can VBA be used to append rows of data from sheet2
from "day.xls" to the last row of the data in sheet1 of
the "hours.xls"?

many thanks.


regards,
Joe



.




Brian

append row
 
Assuming you want all the data in day.xls to be appended
to hours.xls and the data is contiguous (no blank rows or
columns) in the day.xls file:

Workbooks("day.xls").Activate
Range("A1").CurrentRegion.Copy 'Copies the data
Workbooks("hours.xls").Activate
Range("A65536").End(xlUp).Select 'Selects the bottom row
ActiveCell.Offset(1, 0).Paste 'Pastes to the next empty row

-----Original Message-----
Hi,

can VBA be used to append rows of data from sheet2
from "day.xls" to the last row of the data in sheet1 of
the "hours.xls"?

many thanks.


regards,
Joe
.



All times are GMT +1. The time now is 07:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com