Hello,
So, with help of kind people here I was able to make most of my project work, but have hit the hopefully last bump. Basically, I have a worksheet that based on condition decides whether the issue should go after Quality, Logistics or Finances, and then generates an email to be just sent to the responsible person. But, whenever I fill in new cell, all the previous cells are triggered, and therefore if there were previously three sorted problems, after filling new one, four emails are open. Is there a way, how to open outlook just for the new cell?
Here is what the code that calls the emails looks like:
Thank you so much for your help
So, with help of kind people here I was able to make most of my project work, but have hit the hopefully last bump. Basically, I have a worksheet that based on condition decides whether the issue should go after Quality, Logistics or Finances, and then generates an email to be just sent to the responsible person. But, whenever I fill in new cell, all the previous cells are triggered, and therefore if there were previously three sorted problems, after filling new one, four emails are open. Is there a way, how to open outlook just for the new cell?
Here is what the code that calls the emails looks like:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
Dim LastRow As Long
Dim i As Long
LastRow = Range("B" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
If Range("B" & i).Value = "Late delivery" Or Range("B" & i).Value = "Missing delivery" Or Range("B" & i).Value = "Damaged packaging" Or Range("B" & i).Value = "Wrong delivery note" Or Range("B" & i).Value = "Wrong product" Then
Range("D" & i).Value = "Logistics"
End If
If Range("B" & i).Value = "Damaged product" Or Range("B" & i).Value = "Wrong description" Or Range("B" & i).Value = "Different specifications" Then
Range("D" & i).Value = "Quality"
End If
If Range("B" & i).Value = "Missing invoice" Or Range("B" & i).Value = "Wrong price" Or Range("B" & i).Value = "Late payment" Or Range("B" & i).Value = "Wrong invoice" Then
Range("D" & i).Value = "Finances"
End If
If Range("D" & i).Value = "Quality" Then
Call send_mail_outlook_Qvl
End If
If Range("D" & i).Value = "Logistics" Then
Call send_mail_outlook_Log
End If
If Range("D" & i).Value = "Finances" Then
Call send_mail_outlook_Fin
End If
Next i
Application.EnableEvents = True
End Sub
Thank you so much for your help