ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using variables when copying values between worksheets (https://www.excelbanter.com/excel-programming/327342-using-variables-when-copying-values-between-worksheets.html)

[email protected]

Using variables when copying values between worksheets
 
Hello! I am trying to copy values between two worksheets. On the
second worksheet I want to allow users to be able to see scenarios asa
the numbers change. So when the user clicks a command button for the
first copy we have original values. For the second copy the values
will be different. Yet I am having a problem that I can't seem to
capture only the value. I read that PasteSpecial should do the trick
.... yet I am using variables to pass the columns that I happen to be
working with.

With the following I get an error. Any tips or clues? Thanks in
advance.

Worksheets("Sheet1").Cells(5,12).Copy
Sheets("Sheet2").Range(Cells(8, EmptyColumn), Cells
_(8,EmptyColumn+1).PasteSpecial Paste:=xlPasteFormats
Sheets("Sheet2").Range(Cells(8, EmptyColumn), Cells
_(8,EmptyColumn+1).PasteSpecial Paste:=xlPasteValues


Tom Ogilvy

Using variables when copying values between worksheets
 
With Sheets("Sheet2")
Worksheets("Sheet1").Cells(5,12).Copy
.Range(.Cells(8, EmptyColumn), .Cells _
(8,EmptyColumn+1).PasteSpecial Paste:=xlPasteFormats
.Range(.Cells(8, EmptyColumn), .Cells _
(8,EmptyColumn+1).PasteSpecial Paste:=xlPasteValues
End With

--
Regards,
Tom Ogilvy


wrote in message
oups.com...
Hello! I am trying to copy values between two worksheets. On the
second worksheet I want to allow users to be able to see scenarios asa
the numbers change. So when the user clicks a command button for the
first copy we have original values. For the second copy the values
will be different. Yet I am having a problem that I can't seem to
capture only the value. I read that PasteSpecial should do the trick
... yet I am using variables to pass the columns that I happen to be
working with.

With the following I get an error. Any tips or clues? Thanks in
advance.

Worksheets("Sheet1").Cells(5,12).Copy
Sheets("Sheet2").Range(Cells(8, EmptyColumn), Cells
_(8,EmptyColumn+1).PasteSpecial Paste:=xlPasteFormats
Sheets("Sheet2").Range(Cells(8, EmptyColumn), Cells
_(8,EmptyColumn+1).PasteSpecial Paste:=xlPasteValues





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

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