I am currently running this VBA on a worksheet so that data cannot be deleted once it is entered:
Now it has been requested to have an email automatically sent out anytime the cell in a certain column contains data. I think I can accomplish this with this VBA:
What I can't figure out is how to have them both run on the same sheet. I've never really had to use more than one VBA code at a time.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
Target.Worksheet.Unprotect Password:="efficiency"
Target.Locked = True
Target.Worksheet.Protect Password:="efficiency"
End Sub
Now it has been requested to have an email automatically sent out anytime the cell in a certain column contains data. I think I can accomplish this with this VBA:
VBA Code:
Dim xRg As Range
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If Target.Cells.Count > 1 Then Exit Sub
Set xRg = Intersect(Range("D7"), Target)
If xRg Is Nothing Then Exit Sub
If IsNumeric(Target.Value) And Target.Value > 200 Then
Call Mail_small_Text_Outlook
End If
End Sub
Sub Mail_small_Text_Outlook()
Dim xOutApp As Object
Dim xOutMail As Object
Dim xMailBody As String
Set xOutApp = CreateObject("Outlook.Application")
Set xOutMail = xOutApp.CreateItem(0)
xMailBody = "Hi there" & vbNewLine & vbNewLine & _
"This is line 1" & vbNewLine & _
"This is line 2"
On Error Resume Next
With xOutMail
.To = "Email Address"
.CC = ""
.BCC = ""
.Subject = "send by cell value test"
.Body = xMailBody
.Send
End With
On Error GoTo 0
Set xOutMail = Nothing
Set xOutApp = Nothing
End Sub
What I can't figure out is how to have them both run on the same sheet. I've never really had to use more than one VBA code at a time.