Excel 2003 - Macro Help

N

Neil Holden

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?
 
J

joel

When you copy a range of cells you only have to specify in th
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").Copy _
Destination:=.Range("A" & NewRow)
End With

bk.Close savechanges:=False


End Su
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top