Problem while deleting entire row from UserForm

  • Dear Team,


    I had created code for send reminder mail automatically to customers.


    I will update the machine hours details on column "S" and as per the value entered in Column "S" the calculations happen on Column "E: K".

    And I have conditions. Based on my conditions the mail will trigger automatically the particular customer in which row I am entering the values.


    The mails are working properly as per my conditions.


    the code is in Module 2 for triggering mail.


    And I am having UserForm for add, update, delete customers.


    In this Add and update customer is working properly. But when I am deleting any customer through Userform, the mail is triggering automatically and for some of the customers, I am getting an error message.


    The mail should not trigger if I delete the customer. I don't know where is the mistake in this code.


    I uploaded my file here for your reference. Can anyone please check this and correct my mistake.

  • .

    You have a command line in the Worksheet_Change that calls the Send Email macro :


    Code
    1. Private Sub Worksheet_Change(ByVal Target As Range)
    2. Dim r As Integer, cl As Integer
    3. If Not Application.Intersect(Target, Me.Range("S:S")) Is Nothing Then
    4. r = Target.Row
    5. cl = Target.Column
    6. Call Remindermail(r, cl) ' <-------- HERE
    7. End If

    When a record is deleted from the sheet (a Worksheet_Change event occurs), the email is sent.


    You'll need to determine a means of avoiding that when deleting a record.

  • .

    Try this macro to replace the existing one in your UserForm :