ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copying and pasting macro (https://www.excelbanter.com/excel-programming/408982-copying-pasting-macro.html)

Stav19

Copying and pasting macro
 
Hi all

I would like to copy and paste values from one sheet to another, I
wasn't sure how to paste certain parts from one spreadsheet to
another, so got around this by selecting everything and pasting it.

Example:

Select cells B1:C17, copy and paste in new sheet from cell A1. (this
bit was ok, and used a name range)

However my problem is then if I want to copy other cells and paste
them after the above,

eg

B21:C27 copying these and pasting them on the new sheet after the end
of the first paste. I've tried recording just this bit but when I
edited the macro it went a bit wrong...

Can anyone help with this?

thanks!!!

Rick Rothstein \(MVP - VB\)[_1651_]

Copying and pasting macro
 
Something like this maybe? Select the range you want to copy and then run
this macro...

Sub CopySelection()
Dim LastRow As Long
With Worksheets("Sheet2")
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
Selection.Copy Destination:=.Cells(LastRow, "A")
End With
End Sub

Change the Sheet2 reference to the name of the worksheet you want to copy
the current selection to.

Rick


"Stav19" wrote in message
...
Hi all

I would like to copy and paste values from one sheet to another, I
wasn't sure how to paste certain parts from one spreadsheet to
another, so got around this by selecting everything and pasting it.

Example:

Select cells B1:C17, copy and paste in new sheet from cell A1. (this
bit was ok, and used a name range)

However my problem is then if I want to copy other cells and paste
them after the above,

eg

B21:C27 copying these and pasting them on the new sheet after the end
of the first paste. I've tried recording just this bit but when I
edited the macro it went a bit wrong...

Can anyone help with this?

thanks!!!



Stav19

Copying and pasting macro
 
On Apr 8, 2:45*pm, "Rick Rothstein \(MVP - VB\)"
wrote:
Something like this maybe? Select the range you want to copy and then run
this macro...

Sub CopySelection()
* Dim LastRow As Long
* With Worksheets("Sheet2")
* * LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
* * Selection.Copy Destination:=.Cells(LastRow, "A")
* End With
End Sub

Change the Sheet2 reference to the name of the worksheet you want to copy
the current selection to.

Rick

"Stav19" wrote in message

...



Hi all


I would like to copy and paste values from one sheet to another, I
wasn't sure how to paste certain parts from one spreadsheet to
another, so got around this by selecting everything and pasting it.


Example:


Select cells B1:C17, copy and paste in new sheet from cell A1. (this
bit was ok, and used a name range)


However my problem is then if I want to copy other cells and paste
them after the above,


eg


B21:C27 copying these and pasting them on the new sheet after the end
of the first paste. *I've tried recording just this bit but when I
edited the macro it went a bit wrong...


Can anyone help with this?


thanks!!!- Hide quoted text -


- Show quoted text -


Thanks for your help rick, I'll try that and see how it goes!

Stav19

Copying and pasting macro
 
On Apr 8, 2:45*pm, "Rick Rothstein \(MVP - VB\)"
wrote:
Something like this maybe? Select the range you want to copy and then run
this macro...

Sub CopySelection()
* Dim LastRow As Long
* With Worksheets("Sheet2")
* * LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
* * Selection.Copy Destination:=.Cells(LastRow, "A")
* End With
End Sub

Change the Sheet2 reference to the name of the worksheet you want to copy
the current selection to.

Rick

"Stav19" wrote in message

...



Hi all


I would like to copy and paste values from one sheet to another, I
wasn't sure how to paste certain parts from one spreadsheet to
another, so got around this by selecting everything and pasting it.


Example:


Select cells B1:C17, copy and paste in new sheet from cell A1. (this
bit was ok, and used a name range)


However my problem is then if I want to copy other cells and paste
them after the above,


eg


B21:C27 copying these and pasting them on the new sheet after the end
of the first paste. *I've tried recording just this bit but when I
edited the macro it went a bit wrong...


Can anyone help with this?


thanks!!!- Hide quoted text -


- Show quoted text -


Thanks for your help Rick, I'll give that a try and let you know how
it goes!


All times are GMT +1. The time now is 05:31 AM.

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