VBA Question (Copy and Paste)

Tfox2791

New Member
Joined
Nov 21, 2012
Messages
32
I would like to only copy the values and the formating to the new workbook and worksheet. My code currently copies everything and all of the formulas so when the new workbooks are emailed out they show errors because the link is broken. I tried a few different methods but have been unsucessful, any thoughts?

Thanks for your sugesstions and help in advance....

Current Code:
Dim wbThis As Workbook
Dim wbNew As Workbook
Dim ws As Worksheet
Dim strFileName As String
Dim path As String
Dim name As String

Application.ScreenUpdating = False
path = "G:\Student Services\"
Set wbThis = ActiveWorkbook


For Each ws In wbThis.Worksheets

strFileName = "Drop Analysis " & ws.Cells(1, 105).Text & ".xlsx"
name = ws.Cells(1, 105)
If Dir(name) <> "" Then GoTo Blank

ws.Copy

Application.DisplayAlerts = False

Set wbNew = ActiveWorkbook

wbNew.SaveAs Filename:=(path & strFileName)

wbNew.Close
Blank:
Next ws

End Sub
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Hi

Did you try PasteSpecial? For example:

Code:
Sub wigi()
    Range("A1").Copy
    Range("A2").PasteSpecial Paste:=xlPasteValuesAndNumberFormats
End Sub
 
Upvote 0
you can try adding this to your code after you copy the worksheet. The idea is that if the numbers on the copied worksheet are good before you save this will copy and paste special all the values on the sheet before you save as.

Cells.Select
Cells.PasteSpecial xlPasteValuesAndNumberFormats
 
Upvote 0
I tried the paste special route but it doesnt seem to work? I tried to insert ws.PasteSpecial xlPasteValuesAndNumberFormats after Set wbNew = ActiveWorkbook and it give me an error (Method of Paste Special Object _ Worksheet Failed)?
 
Upvote 0
Tfox2791;3929634I tried to insert ws.PasteSpecial xlPasteValuesAndNumberFormats and it give me an error (Method of Paste Special Object _ Worksheet Failed)?[/QUOTE said:
Yes it does, since I showed you in my example that PasteSpecial applies to a range like Range("A2") instead of to a worksheet like ws.
 
Upvote 0

Forum statistics

Threads
1,214,935
Messages
6,122,337
Members
449,077
Latest member
Jocksteriom

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