sashazaliz
New Member
- Joined
- Nov 9, 2009
- Messages
- 46
The following code below is supposed to copy and paste values 3 specific worksheets within my workbook into a new file within the same directory. Everything works like a charm except the cells in bottom portion of the copied worksheets contain #NAME? instead of the actual pasted values. I suspect this is happening because the bottom portion of those worksheets are all user defined functions instead of simple formulas or references. Are there any tweaks I can make to the code in order to avoid this and just produce values while maintaining formats just the top portion. Thank you!
Code:
Option Explicit
Sub PasteValueSheets()
Dim NewName As String
Dim nm As Name
Dim ws As Worksheet
With Application
.ScreenUpdating = False
On Error GoTo ErrCatcher
Sheets(Array("Output RD 50006-50", "Output RD 50007-50", "Output RD 50009-50", "Output RD 50001-50")).Copy
On Error GoTo 0
For Each ws In ActiveWorkbook.Worksheets
ws.Cells.Copy
ws.[A1].PasteSpecial Paste:=xlValues
ws.Cells.Hyperlinks.Delete
Application.CutCopyMode = False
Cells(1, 1).Select
ws.Activate
Next ws
Cells(1, 1).Select
NewName = "OutputPV"
ActiveWorkbook.SaveCopyAs ThisWorkbook.Path & "\" & NewName & Format(Date, "mmddyyyy") & ".xlsx"
ActiveWorkbook.Close SaveChanges:=False
.ScreenUpdating = True
End With
Exit Sub
ErrCatcher:
MsgBox "Specified sheets do not exist within this workbook"
End Sub
Last edited: