Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro not running when a change occurs

I am having trouble getting a macro to "fire" when a cell change is made.
The cell is a formula, and the formula is based on a cell that "refreshes"
every 30 minutes from a web query. When the cell hits a certain value it
should send an email to several workers, but this does not occur.

Any thoughts/suggestions?

here is the code:

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("C11"), rng) Is Nothing Then
If Range("C11").Value < 0 Then MYMACRO
End If
End If
EndMacro:
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Macro not running when a change occurs

From what I'm finding, the dependents are the cells that reference the target
cell. Is that what you want? No matter, I think I'd change it as follows

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
On Error Resume Next
Set rng = Target.Dependents
On Error GoTo 0
If Not rng Is Nothing Then
If Not Intersect(Range("C11"), rng) Is Nothing Then
If Range("C11").Value < 0 Then
MYMACRO
End If
End If
Else
Debug.Print "There are no dependents to cell " & Target.Address
End If
EndMacro:
End Sub

HTH,
Barb Reinhardt


"Macro not running as intended" wrote:

I am having trouble getting a macro to "fire" when a cell change is made.
The cell is a formula, and the formula is based on a cell that "refreshes"
every 30 minutes from a web query. When the cell hits a certain value it
should send an email to several workers, but this does not occur.

Any thoughts/suggestions?

here is the code:

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("C11"), rng) Is Nothing Then
If Range("C11").Value < 0 Then MYMACRO
End If
End If
EndMacro:
End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Macro not running when a change occurs

Thanks for the help so far guys.

I received an error notice when I changed to Calculate...do I need to
specify the event? How do I do that?

"Gord Dibben" wrote:

Worksheet_Change event is not triggered by a calculated value change.

Use Worksheet_Calculate event


Gord Dibben MS Excel MVP


On Thu, 16 Oct 2008 09:52:01 -0700, Macro not running as intended <Macro not
running as wrote:

I am having trouble getting a macro to "fire" when a cell change is made.
The cell is a formula, and the formula is based on a cell that "refreshes"
every 30 minutes from a web query. When the cell hits a certain value it
should send an email to several workers, but this does not occur.

Any thoughts/suggestions?

here is the code:

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("C11"), rng) Is Nothing Then
If Range("C11").Value < 0 Then MYMACRO
End If
End If
EndMacro:
End Sub



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
Need to determine where a change in table occurs Wox Excel Discussion (Misc queries) 6 July 28th 09 02:48 AM
How to change process bar % when macro is running Alex St-Pierre Excel Programming 0 March 12th 08 06:16 PM
Running a macro on cell value change Brettjg Excel Discussion (Misc queries) 2 March 28th 07 02:55 PM
Change event occurs Otto Moehrbach Excel Programming 2 December 2nd 05 04:53 PM
How to change a macro while running others? MJO Excel Programming 4 April 22nd 05 06:51 PM


All times are GMT +1. The time now is 08:14 PM.

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"