+ Reply to Thread
Results 1 to 8 of 8

Email alert VBA

  1. #1
    Registered User
    Join Date
    11-27-2012
    Location
    Örebro, Sweden
    MS-Off Ver
    Excel 2010
    Posts
    7

    Email alert VBA

    Hello everyone!


    I've just registered, and I need some help with an excel email alert. I know quite a bit about programing in general, and even though I'm not super-good at VBA, I still can use and understand it.

    The problem is that I'm not so good with excel.


    This is the problem I need help with:

    I have a column with a date. This date is the date you made the entry in to the row. What I'm trying to do is to get my Excel document to mail me when three weeks have passed from the date I typed in.

    Is this possible to do? As I said, I'm not so good with Excel programing.


    Sorry for my English, I'm not a native English speaker

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Email alert VBA

    Hi,

    One way. I'm assuming there are several different dates in your column and you want the email sent if the latest date in the list is more than 21 days ago.

    So introduce a cell named "CheckDate" and in this cell enter the formula:
    =MAX(A:A)
    assuming column A is the one containing the dates.

    Then create a module level macro as follows

    Please Login or Register  to view this content.
    Then decide what event you want to use to trigger the macro. If you want this to run the in the Workbook open event add a line of code

    Call CheckDate21

    If you want to run this at any time then create a button and attach the macro to the button.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    11-27-2012
    Location
    Örebro, Sweden
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Email alert VBA

    Thanks, this is really helpful!

    I never done anything in excel programing but I guess that I'll type the code in to the command window on that cell (If i press Alt+F8 when tanding on the cell)?


    And I want the document to send an email when three weeks have passed, without me doing anything, no button or nothing I don't understand what you meant with the button macro attachment, sorry :/



    EDIT: Just to be clear, I know jack about macros and stuff in Excel, I can make pretty tables, that's about it, so I don't know how to make macros work.

    Date is in: 2012-11-27 format, but is it better to have it in 11-27-2012 or 27-11-2012 format? Don't know how the code line reads it.
    Last edited by Aladoran; 11-27-2012 at 08:06 AM. Reason: Aditional Information

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Email alert VBA

    Hi,

    Alt-F8 will not help you since that just points to any macros which you already have. In order to create a macro you need to use Alt-F11.

    I'm attaching a workbook with this macro included.

    However you need to decide which event should trigger the macro. At the moment it will trigger every time you open the workbook. If you look in the Workbook Open event in the macro environment you'll see the line of code which calls the macro which exists in Module1.

    You could instead have a clickable button on the face of the worksheet which would set the macro running. The choice is yours. There are other events that you could use. For instance any time you entered a new date in column A, or perhaps some other value in another column.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    11-27-2012
    Location
    Örebro, Sweden
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Email alert VBA

    Okey I got the code to work, but I ain't getting mails :S


    What is the trigger for the macro at the moment? I mean, I don't have a button or anything, so it must be when I open the document, right? But I ain't getting an email :S
    Last edited by Aladoran; 11-29-2012 at 04:33 AM. Reason: Errors

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Email alert VBA

    Hi,

    It works 'out of the box' for me.

    As I said, the trigger is the workbook open event. Obviously you need to ensure there is a valid email address in B3. You can see that I made up an email address 'aladoran@something.com' so whilst no one (unless they happen to have such an email address) will receive it, you will find that you get a bounced Send email message in your inbox.

    I am of course assuming you use Outlook as your email client and not the 'lite' Outloox Express version or any other software.

  7. #7
    Registered User
    Join Date
    11-27-2012
    Location
    Örebro, Sweden
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Email alert VBA

    Oh, I use the companys email client IBM Lotus Notes, I will try to switch to Outlook

  8. #8
    Registered User
    Join Date
    11-27-2012
    Location
    Örebro, Sweden
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Email alert VBA

    We don't use Outlook here, so I never tried it because it has to be Lotus Notes. Does this kind of thing only work with Outlook? It seems kind of wierd becuase I'm just typing in an email.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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