View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default IF Statement and VBA

Sub Mail_ActiveSheet()
Dim wb As Workbook
Dim strdate As String
If Range("A1").Value 800 Then
strdate = Format(Now, "dd-mm-yy h-mm-ss")
Application.ScreenUpdating = False
ActiveSheet.Copy
Set wb = ActiveWorkbook
With wb
.SaveAs "Part of " & ThisWorkbook.Name _
& " " & strdate & ".xls"
.SendMail ", _
"This is the Subject line"
.ChangeFileAccess xlReadOnly
Kill .FullName
. Close False
End With
Application.ScreenUpdating = True
End If
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"na" wrote in message
...
I found some code on the web
(http://www.rondebruin.nl/mail/folder1/mail2.htm) that will open email but

I
need to tweak it a bit. I need to preface the action with an IF statement
and since I don't know VBA I am hoping someone can help me modify what is
wrong:

IF A1 = 800 then

Sub Mail_ActiveSheet()
Dim wb As Workbook
Dim strdate As String
strdate = Format(Now, "dd-mm-yy h-mm-ss")
Application.ScreenUpdating = False
ActiveSheet.Copy
Set wb = ActiveWorkbook
With wb
.SaveAs "Part of " & ThisWorkbook.Name _
& " " & strdate & ".xls"
.SendMail ", _
"This is the Subject line"
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
Application.ScreenUpdating = True
End Sub