I have the following code below below to email and attach sheet "Sales"
i do not want any formula to be shown on the attached sheet. I must only show values and the original format
Sub Email_SalesData()
Dim File As String, strBody As String
Application.ScreenUpdating = False
Application.DisplayAlerts = False
File = Environ$("temp") & "\" & Format(Range("AA2"), "mmm-yy ") & Format(Now, "dd-mmm-yy h-mm-ss") & ".xlsx"
strBody = "Hi " & Sheets("Sales").Range("AC1") & vbNewLine & vbNewLine & _
"Attached, please find " & Sheets("Sales").Range("AA3") & vbNewLine & vbNewLine & _
"Regards" & vbNewLine & vbNewLine & _
"Howard"
ActiveWorkbook.Save
Sheets("Sales").Copy
With Range("A1:O50")
.PasteSpecial xlPasteValues
.PasteSpecial xlPasteFormats
End With
With ActiveWorkbook
.SaveAs Filename:=File, FileFormat:=51
.Close savechanges:=False
End With
With CreateObject("Outlook.Application").CreateItem(0)
.Display
.to = Join(Application.Transpose(Sheets("Sales").Range("AD1:AD3").Value), ";")
.Subject = Sheets("Sales").Range("AA3")
.body = strBody
.Attachments.Add File
'.Send
End With
Kill File
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
However when running the macro, I get run time error "PasteSpecial Method of Range class Failed" and the code below is highlighted
.PasteSpecial xlPasteValues
It would be appreciated if someone could kindly amend my code
Bookmarks