djonik1234
New Member
- Joined
- Mar 30, 2022
- Messages
- 29
- Office Version
- 365
- Platform
- Windows
This code works perfectly if I set my values manually in G Column which trigger column I to change and send emails if I changes to 1 Tool worth. . But if G column has a formula "=MAX(0,D13-E13)" it does not work.
Is there a way for me to reference all those G columns to be able to recognize the formula. The formula for each row changes based on the row number. See screenshot for reference. Thank you for your help.
Is there a way for me to reference all those G columns to be able to recognize the formula. The formula for each row changes based on the row number. See screenshot for reference. Thank you for your help.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Range("G13:G15, G17:G18, G22:G28, G31:G32, G34:G35, G41, G43:G44, G46, G50:G51, G55:G58"), Target) Is Nothing Then
If Target.Offset(0, 2) = "1 Tool Worth" And Cells(Target.Row, 14) = "" Then
Cells(Target.Row, 14) = "Y"
ElseIf Target.Offset(0, 2) = "2 Tools Worth" Or Target.Offset(0, 2) = "3 Tools Worth" Or Target.Offset(0, 2) = "4 Tools Worth" Or Target.Offset(0, 2) = "5 or more" Then
Cells(Target.Row, 14) = ""
End
Else
End
End If
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
strbody = "This is automated email to inform you that inventory status for " & Cells(Target.Row, 2) & " has change to '2 Tools Worth' or less." & vbNewLine & vbNewLine & _
"Confirm there are enough " & Cells(Target.Row, 2) & " for tools that are on schedule to be moved out."
On Error Resume Next
With OutMail
.To = "email"
.cc = ""
.Bcc = ""
.Importance = 2
.Subject = "Low Casters/Fixture Inventory!"
.Body = strbody
.Attachments.Add ("https://corp4.sharepoint.com/:x:/r/sites/TEA-FS-INTD1-PDX-TRAC/Shared%20Documents/Decon%20Tools/Demo%20Fixture%20Inventory/D1X%20Utility%20Cage%20Inventory.xlsm?d=w79404ca8c4c34967921e51ff6ad4e403&csf=1&web=1&e=uXfkpM")
' .Attachments.Add ("My Attachment link")
.Send '.Display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End If
End Sub