Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Worksheet_Change Recursion ARGHH!

Hey all, good to come out here again.
I have some VBA that executes in "Private Sub
Worksheet_Change", and it takes place whenever the user
updates or makes changes to data on the spreadsheet. The
user actually only makes changes in the C column but the
rest of the spreadsheet refreshes accordingly.

Anyway, part of my VBA access another Sheet and copies
info from there to this sheet while also updating all the
cells of the columns (except the C column).

THE PROBLEM: As soon as the VBA starts changing the
values on this sheet, it re-executes the "Private Sub
Worksheet_Change" again and starts the Macro all over
before it ever finishes. It gets caught in a never
ending cycle?? So the VBA is activating itself because
it produces a Worksheet_Change. But I only want it to
run when the user changes a value in the C column????

I want to use "Worksheet_Change" instead of having a
button that the user has to remember to push. What can I
do? Please advise.

DBAL

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Worksheet_Change Recursion ARGHH!

Hi DBAL

You can stop the running of the events when your macro do his work like this

Application.EnableEvents = flase
'your code
Application.EnableEvents = True



--
Regards Ron de Bruin
http://www.rondebruin.nl


"DBAL" wrote in message ...
Hey all, good to come out here again.
I have some VBA that executes in "Private Sub
Worksheet_Change", and it takes place whenever the user
updates or makes changes to data on the spreadsheet. The
user actually only makes changes in the C column but the
rest of the spreadsheet refreshes accordingly.

Anyway, part of my VBA access another Sheet and copies
info from there to this sheet while also updating all the
cells of the columns (except the C column).

THE PROBLEM: As soon as the VBA starts changing the
values on this sheet, it re-executes the "Private Sub
Worksheet_Change" again and starts the Macro all over
before it ever finishes. It gets caught in a never
ending cycle?? So the VBA is activating itself because
it produces a Worksheet_Change. But I only want it to
run when the user changes a value in the C column????

I want to use "Worksheet_Change" instead of having a
button that the user has to remember to push. What can I
do? Please advise.

DBAL



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Worksheet_Change Recursion ARGHH!

also, as a precaution, add an onerror so that if you fall out, you always
re-enable, like

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
'your code

ws_exit:
Application.EnableEvents = True
End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Ron de Bruin" wrote in message
...
Hi DBAL

You can stop the running of the events when your macro do his work like

this

Application.EnableEvents = flase
'your code
Application.EnableEvents = True



--
Regards Ron de Bruin
http://www.rondebruin.nl


"DBAL" wrote in message

...
Hey all, good to come out here again.
I have some VBA that executes in "Private Sub
Worksheet_Change", and it takes place whenever the user
updates or makes changes to data on the spreadsheet. The
user actually only makes changes in the C column but the
rest of the spreadsheet refreshes accordingly.

Anyway, part of my VBA access another Sheet and copies
info from there to this sheet while also updating all the
cells of the columns (except the C column).

THE PROBLEM: As soon as the VBA starts changing the
values on this sheet, it re-executes the "Private Sub
Worksheet_Change" again and starts the Macro all over
before it ever finishes. It gets caught in a never
ending cycle?? So the VBA is activating itself because
it produces a Worksheet_Change. But I only want it to
run when the user changes a value in the C column????

I want to use "Worksheet_Change" instead of having a
button that the user has to remember to push. What can I
do? Please advise.

DBAL





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Worksheet_Change Recursion ARGHH!

The following will test the worksheet change event for changes in column C
only.
This might help ?

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column = 3 Then
MsgBox "its C"
End If
End Sub

Cheers
Nigel

"DBAL" wrote in message
...
Hey all, good to come out here again.
I have some VBA that executes in "Private Sub
Worksheet_Change", and it takes place whenever the user
updates or makes changes to data on the spreadsheet. The
user actually only makes changes in the C column but the
rest of the spreadsheet refreshes accordingly.

Anyway, part of my VBA access another Sheet and copies
info from there to this sheet while also updating all the
cells of the columns (except the C column).

THE PROBLEM: As soon as the VBA starts changing the
values on this sheet, it re-executes the "Private Sub
Worksheet_Change" again and starts the Macro all over
before it ever finishes. It gets caught in a never
ending cycle?? So the VBA is activating itself because
it produces a Worksheet_Change. But I only want it to
run when the user changes a value in the C column????

I want to use "Worksheet_Change" instead of having a
button that the user has to remember to push. What can I
do? Please advise.

DBAL



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Worksheet_Change Recursion ARGHH!

Wow, thanks I knew there had to be a way around this!




-----Original Message-----
Hi DBAL

You can stop the running of the events when your macro

do his work like this

Application.EnableEvents = flase
'your code
Application.EnableEvents = True



--
Regards Ron de Bruin
http://www.rondebruin.nl


"DBAL" wrote in message

...
Hey all, good to come out here again.
I have some VBA that executes in "Private Sub
Worksheet_Change", and it takes place whenever the user
updates or makes changes to data on the spreadsheet.

The
user actually only makes changes in the C column but

the
rest of the spreadsheet refreshes accordingly.

Anyway, part of my VBA access another Sheet and copies
info from there to this sheet while also updating all

the
cells of the columns (except the C column).

THE PROBLEM: As soon as the VBA starts changing the
values on this sheet, it re-executes the "Private Sub
Worksheet_Change" again and starts the Macro all over
before it ever finishes. It gets caught in a never
ending cycle?? So the VBA is activating itself because
it produces a Worksheet_Change. But I only want it to
run when the user changes a value in the C column????

I want to use "Worksheet_Change" instead of having a
button that the user has to remember to push. What

can I
do? Please advise.

DBAL



.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Worksheet_Change Recursion ARGHH!

Great suggestion, I will definitely add this in. Thanks
alot.

DBAL

-----Original Message-----
also, as a precaution, add an onerror so that if you

fall out, you always
re-enable, like

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
'your code

ws_exit:
Application.EnableEvents = True
End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Ron de Bruin" wrote in message
...
Hi DBAL

You can stop the running of the events when your macro

do his work like
this

Application.EnableEvents = flase
'your code
Application.EnableEvents = True



--
Regards Ron de Bruin
http://www.rondebruin.nl


"DBAL" wrote in message

...
Hey all, good to come out here again.
I have some VBA that executes in "Private Sub
Worksheet_Change", and it takes place whenever the

user
updates or makes changes to data on the

spreadsheet. The
user actually only makes changes in the C column but

the
rest of the spreadsheet refreshes accordingly.

Anyway, part of my VBA access another Sheet and

copies
info from there to this sheet while also updating

all the
cells of the columns (except the C column).

THE PROBLEM: As soon as the VBA starts changing the
values on this sheet, it re-executes the "Private Sub
Worksheet_Change" again and starts the Macro all over
before it ever finishes. It gets caught in a never
ending cycle?? So the VBA is activating itself

because
it produces a Worksheet_Change. But I only want it

to
run when the user changes a value in the C column????

I want to use "Worksheet_Change" instead of having a
button that the user has to remember to push. What

can I
do? Please advise.

DBAL





.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Worksheet_Change Recursion ARGHH!

Now this is nice... because it will only run the code
when a change is made in C right? If I put my code in
the middle there. Awesome, let me play with this.

Thanks!
DBAL


-----Original Message-----
The following will test the worksheet change event for

changes in column C
only.
This might help ?

Private Sub Worksheet_SelectionChange(ByVal Target As

Range)
If Target.Column = 3 Then
MsgBox "its C"
End If
End Sub

Cheers
Nigel

"DBAL" wrote in message
...
Hey all, good to come out here again.
I have some VBA that executes in "Private Sub
Worksheet_Change", and it takes place whenever the user
updates or makes changes to data on the spreadsheet.

The
user actually only makes changes in the C column but

the
rest of the spreadsheet refreshes accordingly.

Anyway, part of my VBA access another Sheet and copies
info from there to this sheet while also updating all

the
cells of the columns (except the C column).

THE PROBLEM: As soon as the VBA starts changing the
values on this sheet, it re-executes the "Private Sub
Worksheet_Change" again and starts the Macro all over
before it ever finishes. It gets caught in a never
ending cycle?? So the VBA is activating itself because
it produces a Worksheet_Change. But I only want it to
run when the user changes a value in the C column????

I want to use "Worksheet_Change" instead of having a
button that the user has to remember to push. What

can I
do? Please advise.

DBAL



.

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
Array functions ARGHH! Marc Fleury Excel Worksheet Functions 19 March 16th 05 09:43 PM
Array functions ARGHH! Marc Fleury Excel Discussion (Misc queries) 1 March 16th 05 08:17 PM
Recursion with user defined functions bigJim Excel Programming 1 December 15th 03 01:00 PM
worksheet_change vs. calculate, and worksheet_change not running Tom Ogilvy Excel Programming 1 July 14th 03 02:51 AM
worksheet_change vs. calculate, and worksheet_change not running Ross[_5_] Excel Programming 0 July 13th 03 04:27 PM


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