View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
David David is offline
external usenet poster
 
Posts: 1,560
Default Emailing Worksheet with VBA Code

You're right. Thanks much again. I added another sheet and after the copy
pasted to that sheet so I don't overwrite my original formulas. You might put
a disclaimer in your example that your code does this.

This is what I ended up with:

Set sh = ActiveSheet

Cells.Copy

Sheets("Copy").Select
Set sh2 = ActiveSheet
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Range("A1").Select
Application.CutCopyMode = False

sh2.Select
Range("A1").Select 'To make sure the copy selection is removed

ActiveSheet.Copy
'etc

"Ron de Bruin" wrote:

Look good at the example on my site

ActiveSheet.Copy

is after
Set wb = ActiveWorkbook

in your macro

I must go to work



--
Regards Ron de Bruin
http://www.rondebruin.nl



"David" wrote in message ...
I'm having a tough time figuring out how to email a single worksheet that
used the PriorSheet Function. I've tried Ron's email and tips on a single
sheet, but when I email the sheets with the priorsheet function, I get all
errors in the cells. The email works just fine, just need to get the real
data pasted into the email copy. I really need to fix this before tomorrow
morning. Thanks for any help! Here's the code I'm using with Ron's in there
notated:

Sub Mail_ActiveSheet()
Dim wb As Workbook
Dim strdate As String
Dim FileNameEmail As String
Dim Location As String
Dim LocationNum As String
Dim ForDate As Date
Dim MyArr As Variant
MyArr = Sheets("Setup").Range("Email")

strdate = Format(Now, "mm-dd-yy")
Application.ScreenUpdating = False

Location = ActiveSheet.Range("B3")
LocationNum = ActiveSheet.Range("B4")
ForDate = ActiveSheet.Range("I4")


FileNameEmail = Left(ActiveWorkbook.Name, Len(ActiveWorkbook.Name) - 4)

Set wb = ActiveWorkbook
With wb
'Ron's Code Starts Here
ActiveSheet.Copy
Cells.Copy
Cells.PasteSpecial xlPasteValues
Cells(1).Select
Worksheets(1).Select
Application.CutCopyMode = False
'Ron's Code Stops Here

.SaveAs "Daily " & FileNameEmail & " saved on " & strdate & ".xls"
.SendMail MyArr, "Daily DMR from " & Location & "-" & LocationNum &
" for " & ForDate
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
Application.ScreenUpdating = True
End Sub