Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 64
Default Sending Mail from VBA

Hi all,

I have this bit of code that sends and email everytime the value in cell B1
is equal to 1

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
If Target.Cells.Count 1 Then Exit Sub
On Error GoTo EndMacro
If Not Target.HasFormula Then
Set rng = Target.Dependents
If Not Intersect(Range("B1"), rng) Is Nothing Then
If Range("B1").Value = 1 Then Mail_with_outlook
End If
End If
EndMacro:
End Sub

How can I get the code to work for a range?

e.g if any 1 of the cells between B1:B10 is equal to 1, then activate the
Mail_with_outlook sub? I want to do this as I have a table (i.e. A1:B10),
which I will work my way down every week, and wenever a cell between B1:B10
is equal to 1 then an email is automatically sent.

Thanks

Bhupinder.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Sending Mail from VBA

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
If Not Intersect(Target, Range("B1:B10")) Is Nothing Then
On Error GoTo EndMacro
If Not Target.HasFormula Then
If Target.Value = 1 Then Mail_with_outlook
End If
End If
EndMacro:
End Sub



--
HTH

Bob Phillips

"Bhupinder Rayat" wrote in
message ...
Hi all,

I have this bit of code that sends and email everytime the value in cell

B1
is equal to 1

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
If Target.Cells.Count 1 Then Exit Sub
On Error GoTo EndMacro
If Not Target.HasFormula Then
Set rng = Target.Dependents
If Not Intersect(Range("B1"), rng) Is Nothing Then
If Range("B1").Value = 1 Then Mail_with_outlook
End If
End If
EndMacro:
End Sub

How can I get the code to work for a range?

e.g if any 1 of the cells between B1:B10 is equal to 1, then activate the
Mail_with_outlook sub? I want to do this as I have a table (i.e. A1:B10),
which I will work my way down every week, and wenever a cell between

B1:B10
is equal to 1 then an email is automatically sent.

Thanks

Bhupinder.




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
General mail failure when sending e-mail from Excel Adrienne Excel Discussion (Misc queries) 5 November 4th 05 12:59 PM
Sending E-mail CB Hamlyn Excel Programming 5 July 24th 05 11:48 PM
Sending E-mail litew_8 Excel Worksheet Functions 1 November 21st 04 06:13 AM
Sending e-mail - Ron, you still there? Steph[_3_] Excel Programming 2 September 22nd 04 12:52 AM
Help sending mail... Bob Phillips[_6_] Excel Programming 1 August 12th 04 08:50 PM


All times are GMT +1. The time now is 07:22 AM.

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

About Us

"It's about Microsoft Excel"