ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Paste Special between Spreadsheets (https://www.excelbanter.com/excel-programming/352232-paste-special-between-spreadsheets.html)

Meryl Miller

Paste Special between Spreadsheets
 
Hi -

I am automating some plan data that we have and seem to be running into a
problem using paste special to copy data from one spreadsheet to another. Is
there any restriction that dones not allow this? I have been able to
successfully write VBA code that copies and pastes the data that I need from
one spreadsheet to another - the only issue is that I would really rather
just past the values rather than the formulas as well (hence the need for
paste special). Does anyone have a simple example where they have gotten
this to work?

Thanks,
Meryl

Meryl Miller

Paste Special between Spreadsheets
 
Hi -

I figured it out. Please ignore the previous post.

- Meryl

"Meryl Miller" wrote:

Hi -

I am automating some plan data that we have and seem to be running into a
problem using paste special to copy data from one spreadsheet to another. Is
there any restriction that dones not allow this? I have been able to
successfully write VBA code that copies and pastes the data that I need from
one spreadsheet to another - the only issue is that I would really rather
just past the values rather than the formulas as well (hence the need for
paste special). Does anyone have a simple example where they have gotten
this to work?

Thanks,
Meryl


Kevin B

Paste Special between Spreadsheets
 
The following code selects a contiguous block of cells in Sheet 1 of the
currently active workbook, copies the selection, opens a new workbook, does a
paste special and saves the new workbook.

Sub CopyPSpec()

Dim wb As Workbook
Dim ws As Worksheet

Set wb = ActiveWorkbook
Set ws = wb.Worksheets("Sheet1")

ws.Activate
Range("A1").Select
Selection.CurrentRegion.Select
Selection.Copy
Workbooks.Add
Selection.PasteSpecial Paste:=xlValues
ActiveWorkbook.Save

Set ws = Nothing
Set wb = Nothing
Exit Sub

End Sub

--
Kevin Backmann


"Meryl Miller" wrote:

Hi -

I am automating some plan data that we have and seem to be running into a
problem using paste special to copy data from one spreadsheet to another. Is
there any restriction that dones not allow this? I have been able to
successfully write VBA code that copies and pastes the data that I need from
one spreadsheet to another - the only issue is that I would really rather
just past the values rather than the formulas as well (hence the need for
paste special). Does anyone have a simple example where they have gotten
this to work?

Thanks,
Meryl



All times are GMT +1. The time now is 05:27 PM.

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