Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9
Default Macro if cell value changes

I have the following macro that will send me an email. When I
manually run the macro, it works great. But what I want is to have
the macro sent when someone enter info into the sheet. How can I get
this done?

Thanks
__________________________________________________ _______
Sub Email1()
Dim oSess As Object
Dim oDB As Object
Dim oDoc As Object
Dim oItem As Object
Dim direct As Object
Dim Var As Variant
Dim flag As Boolean

Set oSess = CreateObject("Notes.NotesSession")
Set oDB = oSess.GETDATABASE("", "")
Call oDB.OPENMAIL
flag = True
If Not (oDB.IsOpen) Then flag = oDB.Open("", "")

If Not flag Then
MsgBox "Can't open mail file: " & oDB.SERVER & " " &
oDB.FILEPATH
GoTo exit_SendAttachment
End If
On Error GoTo err_handler

'Building Message
Set oDoc = oDB.CREATEDOCUMENT
Set oItem = oDoc.CREATERICHTEXTITEM("BODY")
oDoc.Form = "Memo"
oDoc.Subject = "Request LCMS Update has been submitted"
oDoc.sendto = "
oDoc.body = "Please review spreadsheet for submission"
oDoc.postdate = Date
oDoc.SaveMessageOnSend = True

'Attaching DATABASE
Call oItem.EmbedObject(1454, "", "I:\Card\@OpsTrain\TSC\LCMS - SDN
Learning\LCMS - SDN Reporting & Updates.xls")
oDoc.visable = True
'Sending Message
oDoc.SEND False
exit_SendAttachment:
On Error Resume Next
Set oSess = Nothing
Set oDB = Nothing
Set oDoc = Nothing
Set oItem = Nothing
'Done
Exit Sub
err_handler:
If Err.Number = 7225 Then
MsgBox "File doesn't exist"
Else
MsgBox Err.Number & " " & Err.Description
End If
On Error GoTo exit_SendAttachment
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,805
Default Macro if cell value changes

Worksheet_Change is executed everytime there is any change... so attach your
code to this macro...

Right click on the worksheet and choose View Code...
you know the drill :-)
--
Always provide your feedback...


"Jimbo" wrote:

I have the following macro that will send me an email. When I
manually run the macro, it works great. But what I want is to have
the macro sent when someone enter info into the sheet. How can I get
this done?

Thanks
__________________________________________________ _______
Sub Email1()
Dim oSess As Object
Dim oDB As Object
Dim oDoc As Object
Dim oItem As Object
Dim direct As Object
Dim Var As Variant
Dim flag As Boolean

Set oSess = CreateObject("Notes.NotesSession")
Set oDB = oSess.GETDATABASE("", "")
Call oDB.OPENMAIL
flag = True
If Not (oDB.IsOpen) Then flag = oDB.Open("", "")

If Not flag Then
MsgBox "Can't open mail file: " & oDB.SERVER & " " &
oDB.FILEPATH
GoTo exit_SendAttachment
End If
On Error GoTo err_handler

'Building Message
Set oDoc = oDB.CREATEDOCUMENT
Set oItem = oDoc.CREATERICHTEXTITEM("BODY")
oDoc.Form = "Memo"
oDoc.Subject = "Request LCMS Update has been submitted"
oDoc.sendto = "
oDoc.body = "Please review spreadsheet for submission"
oDoc.postdate = Date
oDoc.SaveMessageOnSend = True

'Attaching DATABASE
Call oItem.EmbedObject(1454, "", "I:\Card\@OpsTrain\TSC\LCMS - SDN
Learning\LCMS - SDN Reporting & Updates.xls")
oDoc.visable = True
'Sending Message
oDoc.SEND False
exit_SendAttachment:
On Error Resume Next
Set oSess = Nothing
Set oDB = Nothing
Set oDoc = Nothing
Set oItem = Nothing
'Done
Exit Sub
err_handler:
If Err.Number = 7225 Then
MsgBox "File doesn't exist"
Else
MsgBox Err.Number & " " & Err.Description
End If
On Error GoTo exit_SendAttachment
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,344
Default Macro if cell value changes

Hi,

You should add code such as this and then put your code inside it:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim isect As Range
Set isect = Application.Intersect(Range("A2:D10"), Target)
If Not isect Is Nothing Then

"your code here"

End If
End Sub

The problem is that you need to decide what cell or cells trigger this
email. In the example above A2:D10 would trigger the event.

--
Thanks,
Shane Devenshire


"Jimbo" wrote:

I have the following macro that will send me an email. When I
manually run the macro, it works great. But what I want is to have
the macro sent when someone enter info into the sheet. How can I get
this done?

Thanks
__________________________________________________ _______
Sub Email1()
Dim oSess As Object
Dim oDB As Object
Dim oDoc As Object
Dim oItem As Object
Dim direct As Object
Dim Var As Variant
Dim flag As Boolean

Set oSess = CreateObject("Notes.NotesSession")
Set oDB = oSess.GETDATABASE("", "")
Call oDB.OPENMAIL
flag = True
If Not (oDB.IsOpen) Then flag = oDB.Open("", "")

If Not flag Then
MsgBox "Can't open mail file: " & oDB.SERVER & " " &
oDB.FILEPATH
GoTo exit_SendAttachment
End If
On Error GoTo err_handler

'Building Message
Set oDoc = oDB.CREATEDOCUMENT
Set oItem = oDoc.CREATERICHTEXTITEM("BODY")
oDoc.Form = "Memo"
oDoc.Subject = "Request LCMS Update has been submitted"
oDoc.sendto = "
oDoc.body = "Please review spreadsheet for submission"
oDoc.postdate = Date
oDoc.SaveMessageOnSend = True

'Attaching DATABASE
Call oItem.EmbedObject(1454, "", "I:\Card\@OpsTrain\TSC\LCMS - SDN
Learning\LCMS - SDN Reporting & Updates.xls")
oDoc.visable = True
'Sending Message
oDoc.SEND False
exit_SendAttachment:
On Error Resume Next
Set oSess = Nothing
Set oDB = Nothing
Set oDoc = Nothing
Set oItem = Nothing
'Done
Exit Sub
err_handler:
If Err.Number = 7225 Then
MsgBox "File doesn't exist"
Else
MsgBox Err.Number & " " & Err.Description
End If
On Error GoTo exit_SendAttachment
End Sub


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9
Default Macro if cell value changes

Thanks so much! Worked. You're amazing!

On Oct 15, 6:21*pm, ShaneDevenshire
wrote:
Hi,

You should add code such as this and then put your code inside it:

Private Sub Worksheet_Change(ByVal Target As Range)
* * Dim isect As Range
* * Set isect = Application.Intersect(Range("A2:D10"), Target)
* * If Not isect Is Nothing Then

* * * * "your code here"

* * End If
End Sub

The problem is that you need to decide what cell or cells trigger this
email. *In the example above A2:D10 would trigger the event.

--
Thanks,
Shane Devenshire



"Jimbo" wrote:
I have the following macro that will send me an email. * When I
manually run the macro, it works great. *But what I want is to have
the macro sent when someone enter info into the sheet. * How can I get
this done?


Thanks
__________________________________________________ _______
Sub Email1()
* * Dim oSess As Object
* * Dim oDB As Object
* * Dim oDoc As Object
* * Dim oItem As Object
* * Dim direct As Object
* * Dim Var As Variant
* * Dim flag As Boolean


* * Set oSess = CreateObject("Notes.NotesSession")
* * Set oDB = oSess.GETDATABASE("", "")
* * Call oDB.OPENMAIL
* * flag = True
* * If Not (oDB.IsOpen) Then flag = oDB.Open("", "")


* * If Not flag Then
* * * * MsgBox "Can't open mail file: " & oDB.SERVER & " " &
oDB.FILEPATH
* * * * GoTo exit_SendAttachment
* * End If
* * On Error GoTo err_handler


* * *'Building Message
* * Set oDoc = oDB.CREATEDOCUMENT
* * Set oItem = oDoc.CREATERICHTEXTITEM("BODY")
* * oDoc.Form = "Memo"
* * oDoc.Subject = "Request LCMS Update has been submitted"
* * oDoc.sendto = "
* * oDoc.body = "Please review spreadsheet for submission"
* * oDoc.postdate = Date
* * oDoc.SaveMessageOnSend = True


* * *'Attaching DATABASE
* * Call oItem.EmbedObject(1454, "", "I:\Card\@OpsTrain\TSC\LCMS - SDN
Learning\LCMS - SDN Reporting & Updates.xls")
* * oDoc.visable = True
* * *'Sending Message
* * oDoc.SEND False
exit_SendAttachment:
* * On Error Resume Next
* * Set oSess = Nothing
* * Set oDB = Nothing
* * Set oDoc = Nothing
* * Set oItem = Nothing
* * *'Done
* * Exit Sub
err_handler:
* * If Err.Number = 7225 Then
* * * * MsgBox "File doesn't exist"
* * Else
* * * * MsgBox Err.Number & " " & Err.Description
* * End If
* * On Error GoTo exit_SendAttachment
End Sub- Hide quoted text -


- Show quoted text -


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Paste A Cell Formula Into A Cell With A Macro. Minitman Excel Worksheet Functions 0 March 26th 08 04:50 AM
macro to move part of cell contents to another cell icetoad hisself Excel Discussion (Misc queries) 4 November 27th 06 07:19 PM
using a cell value to control a counter inside a macro and displaying macro value ocset Excel Worksheet Functions 1 September 10th 06 05:32 AM
Using macro to copy a part of a cell content to next cell Charles Excel Discussion (Misc queries) 6 May 31st 06 05:57 AM
Macro for cell selection starting with Last Cell Valerie Excel Worksheet Functions 4 December 9th 05 08:25 PM


All times are GMT +1. The time now is 04:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"