Hello everyone,
My skills in VBA are low.
With some research on the web I've reached this:
>>> use code - tags <<<
The macro works if I manually change the value in the cell.
I want the macro to run when someone (a colleague from work) saves the file. So I placed this in workbook module:
Well, of course, it does not work
Ive searched for a solution here in the forum but without success.
Just some details: the colleague add values in cells from different sheets almost everyday. I have another sheet to make some math with those values, where is the first code and D22 cell. All in same workbook.
Can someone help? I feel I am close
My skills in VBA are low.
With some research on the web I've reached this:
>>> use code - tags <<<
Code:
Dim xRg As Range
Private Sub contagem(ByVal Target As Range)
On Error Resume Next
If Target.Cells.Count > 1 Then Exit Sub
Set xRg = Intersect(Range("D22"), Target)
If xRg Is Nothing Then Exit Sub
If IsNumeric(Target.Value) And Target.Value > 45000 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 = "Olá Luisa," & vbNewLine & vbNewLine & _
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxx" & vbNewLine & _
"xxxxxxxxxxxxxxxxxxxx" & vbNewLine & vbNewLine & _
"xxxxxxxxxxxxxxxx"
On Error Resume Next
With xOutMail
.To = "xxxxxxxxx"
.CC = "xxxxxxxxxxx;" & "xxxxxxxxxxxxx"
.BCC = ""
.Subject = "xxxxxxxxxxxxxxxxxxxx"
.Body = xMailBody
.Display 'or use .Send
End With
On Error GoTo 0
Set xOutMail = Nothing
Set xOutApp = Nothing
End Sub
The macro works if I manually change the value in the cell.
I want the macro to run when someone (a colleague from work) saves the file. So I placed this in workbook module:
Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Call Sheet13.contagem
End Sub
Well, of course, it does not work
Ive searched for a solution here in the forum but without success.
Just some details: the colleague add values in cells from different sheets almost everyday. I have another sheet to make some math with those values, where is the first code and D22 cell. All in same workbook.
Can someone help? I feel I am close
Last edited by a moderator: