Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Change Event Endless loop :-(

Hi everybody: I have a macro that triggers other macros depending which
column has changed. The problem is that it enters in an endless because
the other macros change columns again and I enter an endless loop...

As you can see, this macro starts whith a change event

Private Sub Worksheet_Change(ByVal Target As Range)
Dim C As Long
C = Target.Column
Select case
Case is =1
Call Macro1
Case is =2
Call Macro2
End Select
End Sub

Sub Macro 1()
Range("a1").value=100
'Rest of the code here...
'As you can see, this macro change Column 1 so it triggers again the
change event (endless loop)
End Sub

Sub Macro 2()
Range("b1").value=200
'Rest of the code here...
'As you can see, this macro change Column 2 so it triggers again the
change event (endless loop)
End Sub

Can you suggest me any code to avoid the endless loop?

Thank you very much !

---

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Change Event Endless loop :-(


Wrap your code within the Enableevents eg

Private Sub Worksheet_Change(ByVal Target As Range)
Dim C As Long
C = Target.Column

application.enableevents=false

Select case
Case is =1
Call Macro1
Case is =2
Call Macro2
End Select

application.enableevents=true

End Sub


--
Ivan F Moala


------------------------------------------------------------------------
Ivan F Moala's Profile: http://www.excelforum.com/member.php...fo&userid=1954
View this thread: http://www.excelforum.com/showthread...hreadid=490447

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Change Event Endless loop :-(

Thank you very much botn IVAN F MOALA and JE McGimpsey . Your solutions
are perfect and I have solve the problem...

CONGRATULATIONS !!!

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
endless loop help John Excel Programming 1 October 26th 05 04:51 PM
Endless loop? John Excel Programming 24 August 2nd 05 06:41 PM
deleting rows, endless loop maybe ? dick[_2_] Excel Programming 3 June 28th 05 06:35 PM
Interrupting an endless loop davegb Excel Programming 3 March 17th 05 05:06 PM
Endless Loop when using ComboBox1.BoundColumn = 2 shrekut Excel Programming 2 January 12th 04 01:46 PM


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