ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel 2003 - Macro Help (https://www.excelbanter.com/excel-programming/436611-excel-2003-macro-help.html)

Neil Holden

Excel 2003 - Macro Help
 
Hi all Excel Gurus,

I need help. I have an excel workbook with a sheet called template and i
want to create a button to copy a selection of data which is B9:B34 and i
need it to paste the information to another excel workbook with a sheet
called data which will be A:AA and add each row when pressed. When the data
has been copied over i need it to close the data sheet.

Can someone help me please?

joel[_250_]

Excel 2003 - Macro Help
 

When you copy a range of cells you only have to specify in the
destination l;ocation the 1st cell of the range like I did below.



Private Sub CommandButton1_Click()

FName = "c:\temp\abc.xls"
bk = Workbooks.Open(Filename:=FName)

With bk.Sheets("Data")
Lastrow = .Range("A" & Rows.Count).End(xlUp).Row
NewRow = Lastrow + 1

ThisWorkbook.Sheets("Template").Rnage("B9:B34").Co py _
Destination:=.Range("A" & NewRow)
End With

bk.Close savechanges:=False


End Sub


--
joel
------------------------------------------------------------------------
joel's Profile: http://www.thecodecage.com/forumz/member.php?userid=229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=157082

Microsoft Office Help



All times are GMT +1. The time now is 02:55 PM.

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