Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excel VBA to copy entire sheet and past as values

Tags:

excel

vba

I am needing to create a VBA statement that will Copy the entire active sheet and then paste as values - seems pretty simple but I am not familiar with VBA - it would essentially be automating the 'click' in the top left and copy --> paste as values. here is what I am trying:

Sub CopyPasteSheetAsValues()
'Copy and Paste Summary Sheet as Values
Sheets("Summary Build").Cells.Copy
Sheets("Summary Build").Cells.PasteSpecial Paste:=xlPasteValue
End Sub
like image 475
user3496218 Avatar asked Dec 23 '22 11:12

user3496218


1 Answers

You miss an s in xlPasteValues. Also, good to add Application.CutCopyMode = False to avoid the marching ants around your copy area.

Sub CopyPasteSheetAsValues()
    'Copy and Paste Summary Sheet as Values
    Sheets("Summary Build").Cells.Copy
    Sheets("Summary Build").Cells.PasteSpecial Paste:=xlPasteValues
    Application.CutCopyMode = False
End Sub
like image 173
cbasah Avatar answered Jan 30 '23 14:01

cbasah