Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default worksheet change problems

i have worksheet change code that calls another sub when a cell in a range is
changed (actually 2, but i'm only concerned with the 2nd one). but i don't want
it to fire if i blank the cell out, because there is no value to use. so i check
to see if it's blank and then exit the sub. but after i do this, neither
condition runs unless i exit excel and restart it. just closing the workbook
doesn't help.

anyone know why this happens?



Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "C1"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Range(WS_RANGE)) Is Nothing Then
Run_all
End If

'this one is the one i'm referring to
If Not Intersect(Target, Range(PL_Range)) Is Nothing Then
If Target.Value = "" Then Exit Sub
pRow = Target.Row
Batching
End If
On Error GoTo 0
ws_exit:
Application.EnableEvents = True
End Sub



--


Gary




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default worksheet change problems

think i found it, that application events statement.

--


Gary


"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
i have worksheet change code that calls another sub when a cell in a range is
changed (actually 2, but i'm only concerned with the 2nd one). but i don't
want
it to fire if i blank the cell out, because there is no value to use. so i
check
to see if it's blank and then exit the sub. but after i do this, neither
condition runs unless i exit excel and restart it. just closing the workbook
doesn't help.

anyone know why this happens?



Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "C1"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Range(WS_RANGE)) Is Nothing Then
Run_all
End If

'this one is the one i'm referring to
If Not Intersect(Target, Range(PL_Range)) Is Nothing Then
If Target.Value = "" Then Exit Sub
pRow = Target.Row
Batching
End If
On Error GoTo 0
ws_exit:
Application.EnableEvents = True
End Sub



--


Gary






  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default worksheet change problems

The Application.EnableEvents was never set back to true. Most likely you hit
an error which bypassed the enable. I would comment out all your on error
statements and re-run the macro. When you get the error the code will stop
and allow you to fix the problem.


"Gary Keramidas" wrote:

i have worksheet change code that calls another sub when a cell in a range is
changed (actually 2, but i'm only concerned with the 2nd one). but i don't want
it to fire if i blank the cell out, because there is no value to use. so i check
to see if it's blank and then exit the sub. but after i do this, neither
condition runs unless i exit excel and restart it. just closing the workbook
doesn't help.

anyone know why this happens?



Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "C1"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Range(WS_RANGE)) Is Nothing Then
Run_all
End If

'this one is the one i'm referring to
If Not Intersect(Target, Range(PL_Range)) Is Nothing Then
If Target.Value = "" Then Exit Sub
pRow = Target.Row
Batching
End If
On Error GoTo 0
ws_exit:
Application.EnableEvents = True
End Sub



--


Gary





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default worksheet change problems

I believe you meant to write:

If Target.Value = "" Then GoTo ws_exit

which would have correctly reset the application.enableevents flag back to
true.

"Gary Keramidas" wrote:

i have worksheet change code that calls another sub when a cell in a range is
changed (actually 2, but i'm only concerned with the 2nd one). but i don't want
it to fire if i blank the cell out, because there is no value to use. so i check
to see if it's blank and then exit the sub. but after i do this, neither
condition runs unless i exit excel and restart it. just closing the workbook
doesn't help.

anyone know why this happens?



Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "C1"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Range(WS_RANGE)) Is Nothing Then
Run_all
End If

'this one is the one i'm referring to
If Not Intersect(Target, Range(PL_Range)) Is Nothing Then
If Target.Value = "" Then Exit Sub
pRow = Target.Row
Batching
End If
On Error GoTo 0
ws_exit:
Application.EnableEvents = True
End Sub



--


Gary





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
Excel 2007 - problems with macro to change series formula Gill L Charts and Charting in Excel 3 May 21st 10 04:07 AM
R1C1 problems - Can't change Nargile Excel Discussion (Misc queries) 16 June 20th 06 08:10 AM
Cell value change to trigger macro (worksheet change event?) Neil Goldwasser Excel Programming 4 January 10th 06 01:55 PM
change event problems John Excel Programming 4 December 13th 05 05:58 PM
Change Cell from Validated List Not Firing Worksheet Change Event [email protected] Excel Programming 3 October 4th 04 03:00 AM


All times are GMT +1. The time now is 05:47 PM.

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"