ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   PasteSpecial macro (https://www.excelbanter.com/excel-programming/285981-pastespecial-macro.html)

CG Rosén

PasteSpecial macro
 
Good evening,

Need some help to clean up the recorded macro below. Sheet1 is the
ActiveSheet.
Trying to paste the values of Range("A1:A10") to Sheet2. Cant find out the
right syntax.
Thankful for any hints.

Brgds

CG Rosén
---------------------------------------------------------------------
Sheets("Sheet1").Select
Range("A1:A10").Select
Selection.Copy
Sheets("Sheet2").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks
_
:=False, Transpose:=False



Tom Ogilvy

PasteSpecial macro
 
Sheets("Sheet1").Range("A1:A10").Copy
Sheets("Sheet2").Range("A1").PasteSpecial _
Paste:=xlPasteValues, _
Operation:=xlNone, _
SkipBlanks:=False, _
Transpose:=False

Doesn't make any difference which sheet is the activesheet.

Sheets("Sheet2").Range("A1:A10").Value = _
Sheets("Sheet1).Range("A1:A10").Value

is another way to do it.

--
Regards,
Tom Ogilvy


CG Rosén wrote in message
...
Good evening,

Need some help to clean up the recorded macro below. Sheet1 is the
ActiveSheet.
Trying to paste the values of Range("A1:A10") to Sheet2. Cant find out the
right syntax.
Thankful for any hints.

Brgds

CG Rosén
---------------------------------------------------------------------
Sheets("Sheet1").Select
Range("A1:A10").Select
Selection.Copy
Sheets("Sheet2").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,

SkipBlanks
_
:=False, Transpose:=False





Dave Peterson[_3_]

PasteSpecial macro
 
Maybe:

Option Explicit

Sub testme02()

Dim rng As Range
Set rng = Worksheets("sheet1").Range("a1:a10")

rng.Copy
Worksheets("sheet2").Range("a1").PasteSpecial Paste:=xlPasteValues

End Sub

but you could just assign the value, too:

Sub testme02()

Dim rng As Range
Set rng = Worksheets("sheet1").Range("a1:a10")

Worksheets("sheet2").Range("A1") _
.Resize(rng.Rows.Count, rng.Columns.Count).Value _
= rng.Value

End Sub



"CG Rosén" wrote:

Good evening,

Need some help to clean up the recorded macro below. Sheet1 is the
ActiveSheet.
Trying to paste the values of Range("A1:A10") to Sheet2. Cant find out the
right syntax.
Thankful for any hints.

Brgds

CG Rosén
---------------------------------------------------------------------
Sheets("Sheet1").Select
Range("A1:A10").Select
Selection.Copy
Sheets("Sheet2").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks
_
:=False, Transpose:=False


--

Dave Peterson


Peter Atherton[_5_]

PasteSpecial macro
 
CG

You do not have to copy the data, this will perform the
same action

Sub pasteValues()
Sheets("Sheet2").Range("A1:A10").Value = _
Sheets("Sheet1").Range("A1:A10")

End Sub

Regards
Peter
-----Original Message-----
Good evening,

Need some help to clean up the recorded macro below.

Sheet1 is the
ActiveSheet.
Trying to paste the values of Range("A1:A10") to Sheet2.

Cant find out the
right syntax.
Thankful for any hints.

Brgds

CG Rosén
----------------------------------------------------------

-----------
Sheets("Sheet1").Select
Range("A1:A10").Select
Selection.Copy
Sheets("Sheet2").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues,

Operation:=xlNone, SkipBlanks
_
:=False, Transpose:=False


.



All times are GMT +1. The time now is 04:43 PM.

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