+ Reply to Thread
Results 1 to 7 of 7

Modity on current code to prompt due date & auto email

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    09-02-2010
    Location
    singapore
    MS-Off Ver
    MS365
    Posts
    287

    Modity on current code to prompt due date & auto email

    Dear All,

    I have below code from one of the pro in this forum.
    I would like to modify this code into others worksheet.
    Could some one explain to me

    1.
    For i = 3 To Sheets("EXPORT").Range("e65536").End(xlUp).row
    What is the "i" stand for?
    Range("e65536") means what?

    2.
    If Cells(i, 28).Value <= Date + 0 And Cells(i, 29) = "" Then
    Date + 0 will prompt you the due date. What about if i wan macro to prompt me 3 days after due date. How should I amend?




    Option Explicit
    'Sub Auto_Open()

    Sub CheckForExpiryDates()
    Dim ce As Range, i As Long
    Dim OutApp As Object
    Dim OutMail As Object
    Dim strto As String, strcc As String, strbcc As String
    Dim strsub As String, strbody As String
    For i = 3 To Sheets("EXPORT").Range("e65536").End(xlUp).row
    If Cells(i, 28).Value <= Date + 0 And Cells(i, 29) = "" Then '28 = Due Date , 29 = Payment
    Set OutApp = CreateObject("Outlook.Application")
    OutApp.Session.Logon
    Set OutMail = OutApp.CreateItem(0)

    With Sheets("EXPORT")
    strto = .Cells(i, 44).Value '44 = email address
    strcc = "" '.Cells(i, 44).Value
    strbcc = ""
    strsub = "AutoMail: NON PAYMENT"
    strbody = "Hi" & " " & .Cells(i, 13).Value & vbNewLine & vbNewLine & _
    "The Bill for Invoice no." & " " & .Cells(i, 3).Value & " " & _
    "; Customer :" & " " & .Cells(i, 1).Value & " " & _
    "is due on " & .Cells(i, 28).Value & _
    " " & vbNewLine & vbNewLine & _
    "Please request your customer to expedite payment!!!" & _
    vbCrLf & vbCrLf & _
    "If shipment have been arrange, please inform the PIC to update shipment date." & _
    vbCrLf & vbCrLf & _
    "Thank you."
    '.Cells(i, 16) = Now()
    End With

    With OutMail
    .To = strto
    .CC = strcc
    .BCC = strbcc
    .Subject = strsub
    .Body = strbody
    '.Send
    .display

    End With

    Set OutMail = Nothing
    Set OutApp = Nothing
    End If
    Next i
    End Sub
    TIA!!!
    Last edited by cyee; 07-04-2013 at 11:39 PM. Reason: typo error

  2. #2
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Modity on current code to prompt due date & auto email

    1. puts to row 3 to last row with data in column E
    2. not sure what Date + 0 does to code

    to no break the mailing part of the code probably put an IF loop before existing if loop
    for msgbox "3 days till due"
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Modity on current code to prompt due date & auto email

    ok date is for todays date

    so have
    If Cells(i, 28).Value +3 <= Date And Cells(i, 29) = "" Then '28 = Due Date , 29 = Payment
    msgbox "3 days til due"
    end if

  4. #4
    Forum Contributor
    Join Date
    09-02-2010
    Location
    singapore
    MS-Off Ver
    MS365
    Posts
    287

    Re: Modity on current code to prompt due date & auto email

    Hi,

    I have edited but still cant work.
    I attached my sample file here. Hope you could help.

    It is under Module 3 - Sub CheckForExpiryDates_N_Email()

    I would like the VBA to auto email when the due date is expiry after 3 days.
    For Example: due date on 2 July 2013, email will send on 4 July 2013 until column AC is filled.
    Attached Files Attached Files

  5. #5
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Modity on current code to prompt due date & auto email

    Sub CheckForExpiryDates_N_Email()
    Dim ce As Range, i As Long
        Dim OutApp As Object
        Dim OutMail As Object
        Dim strto As String, strcc As String, strbcc As String
        Dim strsub As String, strbody As String
        For i = 5 To Sheets("EXPORT").Range("e65536").End(xlUp).row '5 = fifth row
            
            If Cells(i, 28).Value + 3 <= Date And Cells(i, 29) = "" Then
                MsgBox "3 days till due"
            End If
            
            If Cells(i, 28).Value <= Date + 0 And Cells(i, 29) = "" Then      '28 = Due Date , 29 = Payment
    have the rest of the code as is

    nice touch with the
    MsgBox "No Over Due Found! " & vbCrLf & "Payment Received In Time *\(^_^)/* "

  6. #6
    Forum Contributor
    Join Date
    09-02-2010
    Location
    singapore
    MS-Off Ver
    MS365
    Posts
    287

    Re: Modity on current code to prompt due date & auto email

    The code still unable to help.
    I hereby re-attached my sample.
    Could you help to modify in my sample?
    Attached Files Attached Files

  7. #7
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Modity on current code to prompt due date & auto email

    i looked at your sample
    reason nothing works is your column E is empty and that is what the whole loop functions,....unsure why E was chosen, whoever coded it must have their reasons

    i assume your code was working fine before?

    amended so it works
    if within 3 days it will msgbox you
    if overdue it create will email
    Attached Files Attached Files
    Last edited by humdingaling; 07-05-2013 at 04:31 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1