There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
audio avg avg 8 bios boot browser bsod computer cpu crash css dell desktop driver dvd email error excel explorer firefox firefox 3 freeze game graphics hard drive hardware help please hijackthis hjt install internet internet explorer itunes javascript lan laptop malware missing monitor msn network networking openoffice outlook outlook 2003 outlook express php popups problem problems router seo slow sound sp3 spyware startup trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless word
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
13-May-2008, 12:13 PM #31
I don't have too much knowledge about programming and codes but this is what I did. I copied and pasted the code into the "View Code" section in the sheet 1 tab. I then replaced the email address with my own email address, and I also changed the subject line. I then clicked on run and it is giving me an error ( Runtime Error ' 91' ). I went to the macro security window and I changed it to low, but nothing is happening. Supposedly when any cell on column M says "Buy" Excel should send the email by using Outlook right? I have Outlook installed in the computer and I also installed the ClickYes program under C:\Program Files\Express ClickYes\ClickYes.exe
Is there a way we can talk on the messenger or by phone slurpee55, I really need help doing this.
Zack Barresse's Avatar
Computer Specs
Distinguished Member with 3,302 posts.
 
Join Date: Jul 2004
Location: Oregon, United States
Experience: I'ma learnin'!
13-May-2008, 01:24 PM #32
Yes, if the "Buy XXXX" is in column O, then it all would need to be changed over. The test file I had for some reason was in column M (the formulas). Must've missed the col O thingy.
slurpee55's Avatar
Computer Specs
Distinguished Member with 3,299 posts.
 
Join Date: Oct 2004
Location: Southwest Iowa....
Experience: Currently stupid...
13-May-2008, 01:53 PM #33
Also, does the worksheet name need to be changed in the code Zack, and if so, in what lines?
Zack Barresse's Avatar
Computer Specs
Distinguished Member with 3,302 posts.
 
Join Date: Jul 2004
Location: Oregon, United States
Experience: I'ma learnin'!
13-May-2008, 01:55 PM #34
No, it's self-sustained. Since it is in the worksheet module, I made use of the Me object, so it will refer to whatever class object it is held inside. The only sheet the OP'd need to change is if they already have a sheet named "TimeTemp".
slurpee55's Avatar
Computer Specs
Distinguished Member with 3,299 posts.
 
Join Date: Oct 2004
Location: Southwest Iowa....
Experience: Currently stupid...
13-May-2008, 02:58 PM #35
Quote:
Originally Posted by botello2008 View Post
I don't have too much knowledge about programming and codes but this is what I did. I copied and pasted the code into the "View Code" section in the sheet 1 tab.
Zack, should Botello make a module rather than putting it straight into sheet 1?
Zack Barresse's Avatar
Computer Specs
Distinguished Member with 3,302 posts.
 
Join Date: Jul 2004
Location: Oregon, United States
Experience: I'ma learnin'!
13-May-2008, 03:06 PM #36
It was designed for the worksheet module, as it makes use of the worksheet calculate event. It could go into the ThisWorkbook module with a little altering. We could put it into a standard module as well with a little altering, but I'm not sure what the benefit would be. The other routines/functions could indeed go into a standard module, all except the calculate event code.
__________________
___________
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
Zack Barresse's Avatar
Computer Specs
Distinguished Member with 3,302 posts.
 
Join Date: Jul 2004
Location: Oregon, United States
Experience: I'ma learnin'!
14-May-2008, 11:00 AM #37
Here is the updated code which works for me in the actual file emailed to me...

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, strStock As String
    Dim blnCreatedOL As Boolean, blnCY 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
        MyWs.Range("A1").Value = Date + Time - tWait - 1
    Else
        If MyWs Is Nothing Then Set MyWs = ThisWorkbook.Sheets(sWsName)
        If Len(MyWs.Range("A1").Value) = 0 Then MyWs.Range("A1").Value = Date + Time - tWait - 1
'        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, "O").End(xlUp).Row
    For i = 2 To iLastRow
        If IsError(Me.Cells(i, "O").Value) = False Then
            If Me.Cells(i, "O").Value Like "Buy *" Then
                strStock = strStock & Right$(Me.Cells(i, "O").Value, Len(Me.Cells(i, "O").Value) - 4) & sDelim
            End If
        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
    If Dir("C:\Program Files\Express ClickYes\ClickYes.exe", vbNormal) = "" Then
        blnCY = False
    Else
        Set oWShell = CreateObject("wscript.shell")
        oWShell.Run ("""C:\Program Files\Express ClickYes\ClickYes.exe"" -activate")
        blnCY = True
    End If
    
    'Create a new email message, add particulars
    Set olMail = OL.CreateItem(0)
    olMail.To = "8322983517@messaging.nextel.com"
    olMail.Subject = "TIME TO BUY STOCK"
    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")
    If blnCY = True Then
        olMail.Send
    Else
        olMail.display
    End If
    
    '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
    If blnCY = True Then
        oWShell.Run ("""C:\Program Files\Express ClickYes\ClickYes.exe"" -stop")
    End If
    
ExitHere:
    If blnCreatedOL = True Then OL.Quit
    Call TOGGLEEVENTS(True)
    
End Sub
The other two sub routines were put into a separate module named 'modFunctions'.
slurpee55's Avatar
Computer Specs
Distinguished Member with 3,299 posts.
 
Join Date: Oct 2004
Location: Southwest Iowa....
Experience: Currently stupid...
14-May-2008, 11:04 AM #38
Zack, perhaps it would be best if you posted the file with the code in all the right modules?
Zack Barresse's Avatar
Computer Specs
Distinguished Member with 3,302 posts.
 
Join Date: Jul 2004
Location: Oregon, United States
Experience: I'ma learnin'!
14-May-2008, 12:28 PM #39
If I hear back from botello that it is ok, then yes.
botello2008's Avatar
Junior Member with 10 posts.
 
Join Date: May 2008
Experience: Beginner
14-May-2008, 02:40 PM #40
I got it working now. It is working great. Thank you so much for all your help guys. I really appreciate it. Keep up the good work.
slurpee55's Avatar
Computer Specs
Distinguished Member with 3,299 posts.
 
Join Date: Oct 2004
Location: Southwest Iowa....
Experience: Currently stupid...
14-May-2008, 02:53 PM #41
Well, if you make a bundle on the market, buy Zack a gift! :P
Zack Barresse's Avatar
Computer Specs
Distinguished Member with 3,302 posts.
 
Join Date: Jul 2004
Location: Oregon, United States
Experience: I'ma learnin'!
14-May-2008, 02:53 PM #42
Great! Glad to help botello. Don't forget you can mark this thread as Solved from the Thread Tools menu at the top of the thread.
Zack Barresse's Avatar
Computer Specs
Distinguished Member with 3,302 posts.
 
Join Date: Jul 2004
Location: Oregon, United States
Experience: I'ma learnin'!
14-May-2008, 02:54 PM #43
Quote:
Originally Posted by slurpee55 View Post
Well, if you make a bundle on the market, buy Zack a gift! :P
ROFL!! You're too much slurp.
botello2008's Avatar
Junior Member with 10 posts.
 
Join Date: May 2008
Experience: Beginner
14-May-2008, 03:43 PM #44
I'm starting to invest in the market. For now I am just doing paper trading, I am practicing and learning more until I become kind of an expert in this. I basically wanted to make the process automatic so I didn't need to be checking the computer all the time, this way I will get the alert right at the moment the stock gives me the buying signal. But once I start investing for real and if I make money I promise I will buy you both a gift. Thanks again. Good Work.
slurpee55's Avatar
Computer Specs
Distinguished Member with 3,299 posts.
 
Join Date: Oct 2004
Location: Southwest Iowa....
Experience: Currently stupid...
14-May-2008, 04:21 PM #45
Good luck! In today's market, uh, Extra good luck!!!
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 03:45 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.