Copy worksheets(only values) from one workbook to another

edlim85

Board Regular
Joined
May 4, 2009
Messages
178
hi there,

I tried copying(create a copy) a bunch of worksheets from one workbook to another. I was prompt

'A formula or sheet you want to move or copy contains the name 'body', which already exists on the destination worksheet. Do you want to use this version of the name?

  • to use the name as defined in the destination sheet, click yes
  • to rename the range referred to in the formula or worksheet, click no
As a result, i have to click many times 'yes'. how do i go around this? I only need to copy the values only..

below is my code
Sub PushTable()
Dim wOB As Workbook, wMB As Workbook
Application.ScreenUpdating = False

Workbooks.Open Filename:="c:\A.xlsx"

Set wOB = Workbooks("A.xlsx")
Set wMB = Workbooks("Final.xlsm")
wOB.Activate

wOB.Worksheets(Array("sheet5", "sheet1", "sheet2", "sheet3", "sheet4")).Copy Before:=wMB.Worksheets(1)
wOB.Close SaveChanges:=False

Application.ScreenUpdating = True
End Sub
Pls advise

Regards
Edmund
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Hello Edmund,

You can eliminate those warning messages by temporarily setting DisplayAlerts to False

Code:
Application.DisplayAlerts = False
'.....code that Copies worksheets
'.....
Application.DisplayAlerts = True

The code you are currently using will copy the entire sheets including formulas and formatting. If you only want to copy values only, you would need to step through each of the 5 worksheets in A.xlsx separately doing a Copy > Pastespecial(xlPasteValues) to new or existing sheets in Final.xlsm.
 
Last edited:
Upvote 0
Hi JS411,

The code you are currently using will copy the entire sheets including formulas and formatting. If you only want to copy values only, you would need to step through each of the 5 worksheets in A.xlsx separately doing a Copy > Pastespecial(xlPasteValues) to new or existing sheets in Final.xlsm.

Thanks for your reply. :laugh:
 
Upvote 0

Forum statistics

Threads
1,224,614
Messages
6,179,906
Members
452,949
Latest member
beartooth91

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top