ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   IF Statement and VBA (https://www.excelbanter.com/excel-programming/316666-if-statement-vba.html)

NA

IF Statement and VBA
 
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



Bob Phillips[_6_]

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






All times are GMT +1. The time now is 08:50 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com