A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Perfection! Thanks so much.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
My macro (below) copies a named range "EvalCopy3", then paste it on a newly created worksheet. It works great, but there are some rectangle shapes in the named range (used as macro buttons) - If I set the macro up to do a simple copy and paste the macro buttons are carried over, but the formatting is not - - If I set the macro up to paste the formatting (as is shown below) the page is formatted corretly, but then the macro buttons are not there.
I can't figure out where I'm going wronge here - Thanks.
Dim wks As Worksheet
Dim strName As String
'Copies the evaluation record
Application.Goto Reference:="EvalCopy3"
strName = Selection.Range("A1").Value
On Error Resume Next
Set wks = Worksheets(strName)
On Error GoTo 0
If Not wks Is Nothing Then
MsgBox "The sheet '" & strName & "' already exists!", vbExclamation
Exit Sub
End If
Selection.Copy
'inserts a new worksheet, pastes evaluation recor
Set wks = Sheets.Add(Before:=Sheets("Employee List"))
With wks.Range("A1")
.PasteSpecial Paste:=xlPasteValues
.PasteSpecial Paste:=xlPasteFormats
.PasteSpecial Paste:=xlPasteColumnWidths
FYI - there is more to this macro - but I didn't want to copy the entire thing, just the area where the copy/paste code is.
A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
Perfection! Thanks so much.
Hello,
you can add a regular paste command after the paste special:
Sub test()
Dim wks As Worksheet
Dim strName As String
'Copies the evaluation record
Application.Goto Reference:="EvalCopy3"
strName = Selection.Range("A1").Value
On Error Resume Next
Set wks = Worksheets(strName)
On Error GoTo 0
If Not wks Is Nothing Then
MsgBox "The sheet '" & strName & "' already exists!", vbExclamation
Exit Sub
End If
Selection.Copy
'inserts a new worksheet, pastes evaluation recor
Set wks = Sheets.Add(Before:=Sheets("Employee List"))
With wks.Range("A1")
.PasteSpecial Paste:=xlPasteValues
.PasteSpecial Paste:=xlPasteFormats
.PasteSpecial Paste:=xlPasteColumnWidths
End With
ActiveSheet.Paste
End Sub