There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
audio avg avg 8 blue screen brand new codec computer control panel conversion crash desktop display dos driver duplicate dvd error error message excel explorer file firefox game graphics hardware hijackthis log install installation internet itunes javascript lan laptop macro malware msn music network outlook outlook 2003 outlook express php problem random rundll32 runescape security seo sound sp3 spyware switch tag cloud tech trojan usb video virtumonde virus vista visual basic vundo wallpaper windows windows vista windows xp wireless word xp sp3 youtube
Business Applications
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Business Applications >
Solved: Automatic Email Alerts using Excel


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
botello2008's Avatar
Junior Member with 10 posts.
 
Join Date: May 2008
Experience: Beginner
09-May-2008, 05:17 PM #16
I set up a formula that gives me a message when both conditions I need to be met are true. Basically it just says Buy Stock, but I'd like to see if you can help me to set it up in a way that it also gives me the symbol on Column B along with the message, so that way I can see which stock is giving the message for. In addition to that I want to see if you can help me to set it up so when the Buy "GOOG" Stock message appears Excel can automatically send me the email. I am using Windows XP and Microsoft Excel 2003. I am not using Outlook for my email, but I can use it if that is required to set it up. I am not a programmer, and I just have basic knowledge about Excel so I would really appreciate your help guys. I am attaching the spreadsheet so you can see it and you can work it out. By the way you are going to need to download the demo version of the XLQ program so it can work, you can get the program from www.qmatix.com. If you have any questions please let me know. Again, I would really appreciate your help.

www.qmatix.com


Eleazar Botello
Attached Files
File Type: xls Botello_Stock Analysis.xls (44.5 KB, 7 views)
slurpee55's Avatar
Computer Specs
Distinguished Member with 3,159 posts.
 
Join Date: Oct 2004
Location: Southwest Iowa....
Experience: Currently stupid...
09-May-2008, 05:54 PM #17
Well, your conditional formula could say something like (given that the stock ticker id is always in column B)
Have this in M
=IF(AND(F2>=G2,I2>=J2), "Buy", "Do not Buy Stock") (or =IF(AND(F2>=G2,I2>=J2), "Buy", "")
Then this in N
=IF(M2= "Buy",B2)
and finally in O
=IF(M2="Buy",M2&" "&N2,"")
and send the message from O (in this case, it would say "Buy AEHR"
__________________
Iowa? I could have sworn this was heaven.
Well, I think I can answer this question most successfully in mime.

My theme song...
botello2008's Avatar
Junior Member with 10 posts.
 
Join Date: May 2008
Experience: Beginner
09-May-2008, 09:31 PM #18
I did it and it worked. I got the message telling me "Buy UFPT" for example, that stock met the two conditions today. Now how do I set it up so that when Column O shows the message Excel sends the message to my email inbox, or cell phone?
Zack Barresse's Avatar
Computer Specs
Distinguished Member with 3,211 posts.
 
Join Date: Jul 2004
Location: Oregon, United States
Experience: I'ma learnin'!
09-May-2008, 11:58 PM #19
You need to answer all of the questions regarding the email(s) we asked earlier. I.e. are you using Outlook, do you want to use ClickYes, do you want to use the CDO method, do you want to use the Calculate method, etc. We can't do anything without that information. With it, however, it'll take about 10 minutes and we'll have something for you.
__________________
___________
Regards, Zack - MVP - MS Excel 2005-2008 (If you would like comments in any code, please say so.)

OfficeArticles.com :|: Extreme Excel Tutorial :|: Excel Articles by Ken Puls :|: Excel User Group, by Nick Hodge

What is a Microsoft MVP? :|: Live Tech Support? Click here
slurpee55's Avatar
Computer Specs
Distinguished Member with 3,159 posts.
 
Join Date: Oct 2004
Location: Southwest Iowa....
Experience: Currently stupid...
10-May-2008, 01:48 PM #20
Here I have reached my limit - but I know Zack can quickly write up some code (heck, he may have something like it already) in a flash.
Zack Barresse's Avatar
Computer Specs
Distinguished Member with 3,211 posts.
 
Join Date: Jul 2004
Location: Oregon, United States
Experience: I'ma learnin'!
10-May-2008, 05:02 PM #21
I don't have anything pre-packaged, but I do enough of the Emailing (via Outlook) through VBA I can do this (almost verbatim off the top of my head) in about 5-10 min - tops. Just need the info from the OP.
botello2008's Avatar
Junior Member with 10 posts.
 
Join Date: May 2008
Experience: Beginner
12-May-2008, 09:17 AM #22
Hey Zack thanks for your replies. I've been doing a little bit of research on all the different options you gave me to make this work and I think the easiest and probably the fastest way for you to do it is by using Outlook. I want to use Microsoft Outlook and use the ClickYes program as well. I have modified the spreadsheet to have an event to trigger the email. Well actually I just added three more columns to my original spreadsheet (thanks to Slurpee's suggestions), and I now I have the message that will be delivered to my email every time the two conditions are met. Hopefully this can work the way I need it to work, let me know if you need any other information.

Eleazar Botello
slurpee55's Avatar
Computer Specs
Distinguished Member with 3,159 posts.
 
Join Date: Oct 2004
Location: Southwest Iowa....
Experience: Currently stupid...
12-May-2008, 09:43 AM #23
Zack will be able to write you the code, I am sure. In the meantime, you might want to look at this about ClickYes
http://www.excelguru.ca/node/44
This provides some information on how to select data to send from Excel
http://support.microsoft.com/default...b;en-us;278973
__________________
Iowa? I could have sworn this was heaven.
Well, I think I can answer this question most successfully in mime.

My theme song...
Zack Barresse's Avatar
Computer Specs
Distinguished Member with 3,211 posts.
 
Join Date: Jul 2004
Location: Oregon, United States
Experience: I'ma learnin'!
12-May-2008, 06:59 PM #24
Okay, this seems to work for me in testing...
Code:
Option Explicit

Dim MyWs As Worksheet

Private Sub Worksheet_Calculate()
    
    Dim OL As Object, olMail As Object, oWShell As Object
    Dim i As Long, iLastRow As Long
    Dim strStock As String, blnCreatedOL As Boolean
    Const sDelim As String = ";" 'stock [text] delimiter for multiple stocks
    Const sWsName As String = "TimeTemp"
    Const tWait As Long = 10 'length of time in minutes to wait before another email is dispatched (after calculate)
    
    Call TOGGLEEVENTS(False)
    
    'Create temporary worksheet if not already created
    If SHEETEXISTS(sWsName, ThisWorkbook) = False Then
        Set MyWs = ThisWorkbook.Sheets.Add(after:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count))
        MyWs.Name = sWsName
        MyWs.Visible = xlSheetVeryHidden
    Else
        Debug.Print Format(Date + Time - TimeSerial(0, tWait, 0), "h:mm:ss AM/PM ddd, mmm d, yyyy") & " ~ " & MyWs.Range("A1").Value
        If (Date + Time - TimeSerial(0, tWait, 0)) < MyWs.Range("A1").Value Then GoTo ExitHere
    End If
    
    'Find last row of data, loop through and grab those that say "Buy"
    iLastRow = Me.Cells(Me.Rows.Count, "M").End(xlUp).Row
    For i = 2 To iLastRow
        If Me.Cells(i, "M").Value Like "Buy *" Then
            strStock = strStock & Right$(Me.Cells(i, "M").Value, Len(Me.Cells(i, "M").Value) - 4) & sDelim
        End If
    Next i
    If Right$(strStock, 1) = sDelim Then strStock = Left$(strStock, Len(strStock) - 1)
    If Len(strStock) = 0 Then GoTo ExitHere
    strStock = vbTab & Replace(strStock, sDelim, Chr(10) & vbTab)
    
    'Create Outlook object
    Set OL = GetObject(, "Outlook.Application")
    blnCreatedOL = False
    If OL Is Nothing Then
        Set OL = CreateObject("Outlook.Application")
        blnCreatedOL = True
    End If
    
    'Start ClickYes
    Set oWShell = CreateObject("wscript.shell")
    oWShell.Run ("""C:\Program Files\Express ClickYes\ClickYes.exe"" -activate")
    
    'Create a new email message, add particulars
    Set olMail = OL.CreateItem(0)
    olMail.To = "your@addressHere.com"
    olMail.Subject = "Add subject here"
    olMail.Body = "These items were shown as 'Buy' items:" & vbNewLine & vbNewLine & _
                  strStock & vbNewLine & vbNewLine & _
                  "This email was created automatically on: " & Format(Date + Time, "ddd, mmm d, yyyy, h:mm AM/PM")
    olMail.Send
    
    'Set timer so we don't send an email after each cell calculates
    MyWs.Range("A1").Value = Date + Time
    MyWs.Range("A1").NumberFormat = "h:mm AM/PM ddd, mmm d, yyyy"
    
    'Stop ClickYes if you want
    oWShell.Run ("""C:\Program Files\Express ClickYes\ClickYes.exe"" -stop")
    
ExitHere:
    If blnCreatedOL = True Then OL.Quit
    Call TOGGLEEVENTS(True)
    
End Sub

Public Sub TOGGLEEVENTS(ByVal blnState As Boolean)
'Originally written by Zack Barresse
    With Application
        .Calculation = xlCalculationManual ' -4135 (manual)
        .DisplayAlerts = blnState
        .EnableEvents = blnState
        .ScreenUpdating = blnState
        If blnState Then .Calculation = xlCalculationAutomatic ' -4105 (auto)
        If blnState Then .CutCopyMode = False
        If blnState Then .StatusBar = False
    End With
End Sub

Public Function SHEETEXISTS(wsName As String, Optional wkb As Workbook) As Boolean
    If wkb Is Nothing Then
        If ActiveWorkbook Is Nothing Then Exit Function
        Set wkb = ActiveWorkbook
    End If
    On Error Resume Next
    SHEETEXISTS = Len(wkb.Sheets(wsName).Name)
End Function
This all goes into your worksheet module. So right click the sheet tab with your data, select View Code, past in there. Please make sure you look through the code because there are things you need to customize. I did put a list of the available stocks set to "Buy" in the body of the email in a delimited list. If this gets very long, it may make the email message lengthy.

There is one thing we didn't talk about although I did add for it. And that is on each cell calculation, if it meets the criteria, an email would be dispatched for each cell which meets your "Buy" criteria. This is not good (at least I'm assuming you don't want this). So in order to counteract that, I added a hidden sheet and set the last time an email was created in cell A1 of that sheet. Then when the routine is run it checks that cell for its value. If the current date/time is not greater than the value found plus the time to wait (set as a constant - which is the big reason you need to read the code!) then an email will not be created. In essence, you can run through one entire calculation and generate an email. Note that you may want to expand that time, which is a whole number and is expressed in minutes in the code. I have it defaulted to 10 minutes.

Set your email address and the subject. Note this does not have a lot of error handling or comments. I can adjust either one of those if you like, you just need to tell me. It assumes you have the ClickYes program installed, as well as Outlook. We can dummy-proof it as much as you want, again just let us know.

Let us know how this works for you.
__________________
___________
Regards, Zack - MVP - MS Excel 2005-2008 (If you would like comments in any code, please say so.)

OfficeArticles.com :|: Extreme Excel Tutorial :|: Excel Articles by Ken Puls :|: Excel User Group, by Nick Hodge

What is a Microsoft MVP? :|: Live Tech Support? Click here
webarchitect's Avatar
Computer Specs
Junior Member with 3 posts.
 
Join Date: May 2008
Location: Vienna, Virginia
Experience: Beginner
12-May-2008, 08:09 PM #25
So how did it go? I'm really waiting if this works, since I have a slightly similar problem.
botello2008's Avatar
Junior Member with 10 posts.
 
Join Date: May 2008
Experience: Beginner
12-May-2008, 09:33 PM #26
Hey Zack, thanks for writing the code, I am just testing it and apparently it didn't work for me, I'm not sure if I'm doing something wrong, probably I am. I put my email address and subject for the email, but it's not working. I think you set up the code to send the message on column M instead of the one on column O where I have the actual message I want delivered to my email address. Is there a way we can talk on the phone or by instant messenger so you can help me out testing this code. I can send you the program so you can test it. Please let me know if it is possible that we can talk. My email address is botello2006_ at_yahoo.com

Last edited by botello2008 : 13-May-2008 10:17 AM.
slurpee55's Avatar
Computer Specs
Distinguished Member with 3,159 posts.
 
Join Date: Oct 2004
Location: Southwest Iowa....
Experience: Currently stupid...
13-May-2008, 09:44 AM #27
botello, if you can still edit your previous post, do so by replacing the @ in your email with "at" or something like that - spambots troll everywhere.
also, if you set up your extra formulas like I suggested, Zack's code fires when this line becomes true in column M
=IF(AND(F2>=G2,I2>=J2), "Buy", "Do not Buy Stock") (or =IF(AND(F2>=G2,I2>=J2), "Buy", "")

Zack, nice code - however, shouldn't this line
strStock = strStock & Right$(Me.Cells(i, "M").Value, Len(Me.Cells(i, "M").Value) - 4) & sDelim
reference column O in order to get the value of "Buy UFPT" or whatever?
__________________
Iowa? I could have sworn this was heaven.
Well, I think I can answer this question most successfully in mime.

My theme song...
botello2008's Avatar
Junior Member with 10 posts.
 
Join Date: May 2008
Experience: Beginner
13-May-2008, 10:24 AM #28
Thanks for letting me know that slurpee55, I just edited my last post.
slurpee55's Avatar
Computer Specs
Distinguished Member with 3,159 posts.
 
Join Date: Oct 2004
Location: Southwest Iowa....
Experience: Currently stupid...
13-May-2008, 11:15 AM #29
Smile questions
Quote:
Originally Posted by botello2008 View Post
Hey Zack, thanks for writing the code, I am just testing it and apparently it didn't work for me, I'm not sure if I'm doing something wrong, probably I am. I put my email address and subject for the email, but it's not working. I think you set up the code to send the message on column M instead of the one on column O where I have the actual message I want delivered to my email address. Is there a way we can talk on the phone or by instant messenger so you can help me out testing this code. I can send you the program so you can test it. Please let me know if it is possible that we can talk. My email address is botello2006_ at_yahoo.com
Botello, what happens when you run it? Are you getting an error message?
Do you have Outlook installed properly? And did you install ClickYes in the same location as is lists in the code?
Rollin_Again's Avatar
Distinguished Member with 2,581 posts.
 
Join Date: Sep 2003
Location: Atlanta, GA - Planet Earth
Experience: Brilliant When Sober
13-May-2008, 11:28 AM #30
Also make sure to check the Macro security level in your workbook. It should be set to LOW

Regards,
Rollin
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 10:56 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.