Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Macro no longer runs

I have the following code in my worksheeet:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Application.Intersect(Target, Range("C3:H52")) Is Nothing Then Exit Sub
Application.EnableEvents = False
SetRisingRent
Application.EnableEvents = True
End Sub

When I change any value in the specified range it automatically runs the
SetRisingRent macro (a goal seek calculation), but as of today a fault
occurred due to bad data and it suddenly stopped running automatically.

I traced the failure to run automatically to Application.EnableEvents =
False having run but not the later line setting it back to true.

Can I trap this possibility in my code? In Delphi I am used to a structure
like below where the code in the "finally" block is always executed even if
a fault occurs but I can't see an equivalent in VB:

Private sub ....
If Application.Intersect(Target, Range("C3:H52")) Is Nothing Then Exit Sub
Application.EnableEvents = False
try
SetRisingRent
finally
Application.EnableEvents = True
end


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default Macro no longer runs

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
On Error GoTo ws_exit:
If Application.Intersect(Target, Range("C3:H52")) Is Nothing Then Exit Sub
Application.EnableEvents = False
SetRisingRent

ws_exit:
Application.EnableEvents = True
End Sub

--
HTH

Bob Phillips

"Lorne" wrote in message
...
I have the following code in my worksheeet:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Application.Intersect(Target, Range("C3:H52")) Is Nothing Then Exit

Sub
Application.EnableEvents = False
SetRisingRent
Application.EnableEvents = True
End Sub

When I change any value in the specified range it automatically runs the
SetRisingRent macro (a goal seek calculation), but as of today a fault
occurred due to bad data and it suddenly stopped running automatically.

I traced the failure to run automatically to Application.EnableEvents =
False having run but not the later line setting it back to true.

Can I trap this possibility in my code? In Delphi I am used to a

structure
like below where the code in the "finally" block is always executed even

if
a fault occurs but I can't see an equivalent in VB:

Private sub ....
If Application.Intersect(Target, Range("C3:H52")) Is Nothing Then Exit

Sub
Application.EnableEvents = False
try
SetRisingRent
finally
Application.EnableEvents = True
end




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Macro no longer runs

Many thanks


"Bob Phillips" wrote in message
...
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
On Error GoTo ws_exit:
If Application.Intersect(Target, Range("C3:H52")) Is Nothing Then Exit
Sub
Application.EnableEvents = False
SetRisingRent

ws_exit:
Application.EnableEvents = True
End Sub

--
HTH

Bob Phillips

"Lorne" wrote in message
...
I have the following code in my worksheeet:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Application.Intersect(Target, Range("C3:H52")) Is Nothing Then Exit

Sub
Application.EnableEvents = False
SetRisingRent
Application.EnableEvents = True
End Sub

When I change any value in the specified range it automatically runs the
SetRisingRent macro (a goal seek calculation), but as of today a fault
occurred due to bad data and it suddenly stopped running automatically.

I traced the failure to run automatically to Application.EnableEvents =
False having run but not the later line setting it back to true.

Can I trap this possibility in my code? In Delphi I am used to a

structure
like below where the code in the "finally" block is always executed even

if
a fault occurs but I can't see an equivalent in VB:

Private sub ....
If Application.Intersect(Target, Range("C3:H52")) Is Nothing Then Exit

Sub
Application.EnableEvents = False
try
SetRisingRent
finally
Application.EnableEvents = True
end






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
VBA macro runs fine, but freezes if I try to do ANYTHING else whileit runs Rruffpaw Setting up and Configuration of Excel 1 September 17th 11 01:25 PM
My excel macro recorder no longer shows up when recording macro jack Excel Discussion (Misc queries) 3 February 5th 07 08:22 PM
One macro runs then it auto runs another macro PG Excel Discussion (Misc queries) 2 September 1st 06 09:30 PM
Custom Toolbar Button No Longer Runs Assigned Macro Bryan Excel Discussion (Misc queries) 1 April 10th 06 06:02 PM
Which Macro Runs...? Bill Martin Excel Discussion (Misc queries) 7 September 29th 05 12:42 PM


All times are GMT +1. The time now is 06:06 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"