I currently have a macro that copies data from one sheet and archives it in another sheet. The issue that I have is that it is copying and pasting the formulas and it need to copy and paste values only.
Sub Archive_Execution()
Dim mainworkbook As Workbook
Set mainworkbook = ActiveWorkbook
Dim rangeName
Dim strDataRange As Range
Dim keyRange As Range
rangeName = "Archive_Execution"
Application.Goto Reference:=rangeName
Selection.Copy
Sheets("Archive Execution").Activate
Range("A" & Rows.Count).End(xlUp).Offset(1).Select
mainworkbook.Sheets("Archive Execution").Paste
Sheets("Archive Execution").Activate
Set strDataRange = Range("A2:AA1000000")
Set keyRange = Range("D1")
strDataRange.Sort Key1:=keyRange, Order1:=xlAscending
End Sub
Any help would be greatly appreciated on tweaking my code so that only values are pasted not formulas
mainworkbook.Sheets("Archive Execution").Pastewithmainworkbook.Sheets("Archive Execution").PasteSpecial xlPasteValuesbut I'd recommend rethinking your code to avoid usingSelect,CopyandPaste. Instead you can just set the cells in the new worksheet to the values you are importing.Sheets("Archive Execution").Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial xlPasteValues