ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   copy and paste (https://www.excelbanter.com/excel-programming/320768-copy-paste.html)

Henrik

copy and paste
 
Hi,

Would anyone know how to write a vba code that does the following:

copies sheet1 (a1:a10)
pastes it to sheet2 (a1:a10)

copies sheet1 (b1:b10)
pastes it to sheet3 (a1:a10)

your help is greatly appreciated!



Fredrik Wahlgren

copy and paste
 

"Henrik" wrote in message
...
Hi,

Would anyone know how to write a vba code that does the following:

copies sheet1 (a1:a10)
pastes it to sheet2 (a1:a10)

copies sheet1 (b1:b10)
pastes it to sheet3 (a1:a10)

your help is greatly appreciated!



I believe this is what you want
/Fredrik

Sub MyCopy()
Sheets("Sheet1").Select
Range("A1:A10").Select
Selection.Copy
Sheets("Sheet2").Select
Range("A1:A10").Select
ActiveSheet.Paste

Sheets("Sheet1").Select
Range("B1:B10").Select
Selection.Copy
Sheets("Sheet3").Select
Range("A1:A10").Select
ActiveSheet.Paste
End Sub



Trevor Shuttleworth

copy and paste
 
Or, another way:

Sub test4()
Sheets("Sheet1").Range("A1:A10").Copy Sheets("Sheet2").Range("A1:A10")
Sheets("Sheet1").Range("B1:B10").Copy Sheets("Sheet3").Range("A1:A10")
End Sub

Regards

Trevor


"Fredrik Wahlgren" wrote in message
...

"Henrik" wrote in message
...
Hi,

Would anyone know how to write a vba code that does the following:

copies sheet1 (a1:a10)
pastes it to sheet2 (a1:a10)

copies sheet1 (b1:b10)
pastes it to sheet3 (a1:a10)

your help is greatly appreciated!



I believe this is what you want
/Fredrik

Sub MyCopy()
Sheets("Sheet1").Select
Range("A1:A10").Select
Selection.Copy
Sheets("Sheet2").Select
Range("A1:A10").Select
ActiveSheet.Paste

Sheets("Sheet1").Select
Range("B1:B10").Select
Selection.Copy
Sheets("Sheet3").Select
Range("A1:A10").Select
ActiveSheet.Paste
End Sub





Norman Jones

copy and paste
 
Hi Henrik,

Sub Tester()
Sheets("Sheet1").Range("A1:A10").Copy
ActiveSheet.Paste Destination:=Sheets("Sheet2").Range("A1")

Sheets("Sheet2").Range("B1:B10").Copy
ActiveSheet.Paste Destination:=Sheets("Sheet3").Range("A1")
Application.CutCopyMode = False

End Sub

---
Regards,
Norman



"Henrik" wrote in message
...
Hi,

Would anyone know how to write a vba code that does the following:

copies sheet1 (a1:a10)
pastes it to sheet2 (a1:a10)

copies sheet1 (b1:b10)
pastes it to sheet3 (a1:a10)

your help is greatly appreciated!






All times are GMT +1. The time now is 06:16 AM.

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