ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy and Paste Macro Help please.... (https://www.excelbanter.com/excel-programming/285404-copy-paste-macro-help-please.html)

andy F

Copy and Paste Macro Help please....
 
Hi All,

Please forgive me if I have posted in the wrong area. This is the first
time I have attempted to create a macro in excel, so please bear with
me.

What I am trying to do is to set up a worksheet with a command button
on it and when it is clicked it will copy values of specific cells in
another workbook and paste them in specific cells within the current
worksheet.

I have tryed to record a macro, done this no problem but it isn't what
I am after. Does anyone have a couple of lines of code that I could
accomplish this.

I can create the command button but I am stuck on the code to carry out
a copy and paste function.

I have done a search on the forum, but I have found nothing there, If
someone could point me in the right direction.


Many Thanks in advance

Andy


---
Message posted from http://www.ExcelForum.com/


andy F

Copy and Paste Macro Help please....
 
Hi All,

I have just managed to figure it out using the following:

Sheets("Sheet1").Select
Sheet1.Range("H3:H10").Select
Selection.Copy
Sheets("Sheet2").Select
Range("A1").Select
ActiveSheet.Paste

How would I convert this to select a different workbook that was say in
a location of C:\folder\filename.xls

Many Thanks


---
Message posted from http://www.ExcelForum.com/


Don Guillett[_4_]

Copy and Paste Macro Help please....
 
Can be shortened to and can be done without any selections from anywhere.

Sheet1.Range("H3:H10").Copy Sheets("Sheet2").Range("A1")

--
Don Guillett
SalesAid Software

"andy F" wrote in message
...
Hi All,

I have just managed to figure it out using the following:

Sheets("Sheet1").Select
Sheet1.Range("H3:H10").Select
Selection.Copy
Sheets("Sheet2").Select
Range("A1").Select
ActiveSheet.Paste

How would I convert this to select a different workbook that was say in
a location of C:\folder\filename.xls

Many Thanks


---
Message posted from
http://www.ExcelForum.com/





All times are GMT +1. The time now is 08:15 PM.

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