ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Pastespecial code (https://www.excelbanter.com/excel-programming/367391-pastespecial-code.html)

Rayo K

Pastespecial code
 
Please help!

I have the following code that copies and pastes cell values from one sheet
to another based on a line number that is entered by the user. For some
reason, VB claims the last line with the pasteSpecial operation has incorrect
syntax. It is asking me to set it equal to an expression (!?!). I must be
doing something wrong but it looks just like the example, and TagInfo is a
valid range. What am I missing?


Dim LineInfo As Range
Dim TagInfo As Range
Dim TargetLine As Integer

TargetLine = Sheets("Tag Entry").Range("F6").Value


Set LineInfo = Sheets("Tally").Range("E2:J2").Offset(TargetLine, 0)
Set TagInfo = Sheets("Tag Entry").Range("C6:C11")



'Copy and paste line info for the selected line
LineInfo.Copy
TagInfo.PasteSpecial(xlPasteValues,xlPasteSpecialO perationNone,False,True)


Ardus Petus

Pastespecial code
 
Drop the parenthesis:
TagInfo.PasteSpecial xlPasteValues, xlPasteSpecialOperationNone, False, True

HTH
--
AP

"Rayo K" a écrit dans le message de news:
...
Please help!

I have the following code that copies and pastes cell values from one
sheet
to another based on a line number that is entered by the user. For some
reason, VB claims the last line with the pasteSpecial operation has
incorrect
syntax. It is asking me to set it equal to an expression (!?!). I must be
doing something wrong but it looks just like the example, and TagInfo is a
valid range. What am I missing?


Dim LineInfo As Range
Dim TagInfo As Range
Dim TargetLine As Integer

TargetLine = Sheets("Tag Entry").Range("F6").Value


Set LineInfo = Sheets("Tally").Range("E2:J2").Offset(TargetLine, 0)
Set TagInfo = Sheets("Tag Entry").Range("C6:C11")



'Copy and paste line info for the selected line
LineInfo.Copy
TagInfo.PasteSpecial(xlPasteValues,xlPasteSpecialO perationNone,False,True)





All times are GMT +1. The time now is 11:12 AM.

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