Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Stop Capture Event


Dears,

Sometimes I work with worksheet event to capture change event, but
right after that event I change some other things in this sheet but I
dont want worksheet_Change event procedure run like a recursion. So I
want VBA to capture this event. How can I do this?

Thanks for any reply

OverAC

-------
English is not my mother tounge, hope that you can understand what I
want to explain


--
OverAC
------------------------------------------------------------------------
OverAC's Profile: http://www.excelforum.com/member.php...o&userid=32396
View this thread: http://www.excelforum.com/showthread...hreadid=531826

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Stop Capture Event

Test the cell being changed

'-----------------------------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
'-----------------------------------------------------------------
Const WS_RANGE As String = "H1:H10"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
'do your stuff
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"OverAC" wrote in
message ...

Dears,

Sometimes I work with worksheet event to capture change event, but
right after that event I change some other things in this sheet but I
dont want worksheet_Change event procedure run like a recursion. So I
want VBA to capture this event. How can I do this?

Thanks for any reply

OverAC

-------
English is not my mother tounge, hope that you can understand what I
want to explain


--
OverAC
------------------------------------------------------------------------
OverAC's Profile:

http://www.excelforum.com/member.php...o&userid=32396
View this thread: http://www.excelforum.com/showthread...hreadid=531826



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Stop Capture Event


There may be some neater way of soving the problem, but I use a boolean
flag to check to see if the event has been triggered, depending on your
code it may need to be a public variable.

So on the first trigger of the change event set a flag
(e.g.blnfirstTime) at the end of the proc to true.

when the event is triggered again, evaluate the flag at the beginning
of the procedure and finish the sub neatly if needed.


--
MattShoreson
------------------------------------------------------------------------
MattShoreson's Profile: http://www.excelforum.com/member.php...fo&userid=3472
View this thread: http://www.excelforum.com/showthread...hreadid=531826

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Stop Capture Event


Code:
--------------------
Application.EnableEvents = False
Application.EnableEvents = True
--------------------

Thanks Bob, that's so great. That's all I need

Dear MattShoreson,

I used to code like what you said. But from now on It will change.

Thank you all.

OverAC


--
OverAC
------------------------------------------------------------------------
OverAC's Profile: http://www.excelforum.com/member.php...o&userid=32396
View this thread: http://www.excelforum.com/showthread...hreadid=531826

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Stop Capture Event

Matt,

Excel provides its own event flag that you can use. See the example that I
posted.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"MattShoreson"
wrote in message
news:MattShoreson.263hiy_1144750503.4506@excelforu m-nospam.com...

There may be some neater way of soving the problem, but I use a boolean
flag to check to see if the event has been triggered, depending on your
code it may need to be a public variable.

So on the first trigger of the change event set a flag
(e.g.blnfirstTime) at the end of the proc to true.

when the event is triggered again, evaluate the flag at the beginning
of the procedure and finish the sub neatly if needed.


--
MattShoreson
------------------------------------------------------------------------
MattShoreson's Profile:

http://www.excelforum.com/member.php...fo&userid=3472
View this thread: http://www.excelforum.com/showthread...hreadid=531826





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
Capture the hyperlink event before it goes to the link Korekiyo Baisotei Excel Discussion (Misc queries) 0 September 25th 08 05:53 AM
Any way to capture an Autofilter event? mrwaller Excel Programming 1 January 20th 06 06:15 PM
Capture scrolling event Allen[_12_] Excel Programming 2 April 22nd 04 03:37 AM
capture paste event into a cell No Name Excel Programming 3 January 30th 04 07:24 PM
VBA capture File SaveAs Event Linda Mcfarlane Excel Programming 2 September 17th 03 04:06 AM


All times are GMT +1. The time now is 07:41 AM.

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"