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 events - when are they triggered!


Hi All

Could someone tell me if the worksheet_change event of say Sheet1 wil
be triggered when the value in a cell on this worksheet (sheet1 tha
is) is changed by the worksheet_change event of another worksheet sa
sheet2?

I know that it won't be triggered off when the value in a cell i
sheet1 gets changed by Visual Basic or by external links but in thi
case I am not so sure!!!!


Thanks in advance and best regards!


Deepa

--
agarwaldv
-----------------------------------------------------------------------
agarwaldvk's Profile: http://www.excelforum.com/member.php...fo&userid=1134
View this thread: http://www.excelforum.com/showthread.php?threadid=26411

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Worksheet events - when are they triggered!

Your second statement is incorrect. The Worksheet_Change event fires
whenever a cell in the worksheet is changed by manual entry or external
link. It will also fire when an entry is made via VBA, so try:

Sheet1:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Select Case Target.Address(False, False)
Case "A1"
MsgBox "Fired on Sheet1!A1"
With Sheets(2).Range("B1")
.Value = .Value + 1
End With
MsgBox "Done with Sheet1!A1"
Case "B1"
MsgBox "Fired on Sheet1!B1"
Case Else
End Select
End Sub

Sheet2:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Select Case Target.Address(False, False)
Case "A1"
MsgBox "Fired on Sheet2!A1"
With Sheets(1).Range("B1")
.Value = .Value + 1
End With
MsgBox "Done with Sheet2!A1"
Case "B1"
MsgBox "Fired on Sheet2!B1"
Case Else
End Select
End Sub

Whether the change is made from the same worksheet's _Change() event or
a different sheet's _Change() event doesn't matter.

To avoid firing when making a change via VBA, use
Application.EnableEvents = False:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Select Case Target.Address(False, False)
Case "A1"
Application.EnableEvents = False
MsgBox "Fired on Sheet1!A1"
With Sheets(2).Range("B1")
.Value = .Value + 1
End With
MsgBox "Done with Sheet1!A1"
Application.EnableEvents = True
Case "B1"
MsgBox "Fired on Sheet1!B1"
Case Else
End Select
End Sub



In article ,
agarwaldvk wrote:

Could someone tell me if the worksheet_change event of say Sheet1 will
be triggered when the value in a cell on this worksheet (sheet1 that
is) is changed by the worksheet_change event of another worksheet say
sheet2?

I know that it won't be triggered off when the value in a cell in
sheet1 gets changed by Visual Basic or by external links but in this
case I am not so sure!!!!


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
Worksheet Events DCSwearingen Excel Discussion (Misc queries) 2 May 24th 06 10:42 PM
Combobox Click event triggered when copying worksheet Tom Ogilvy Excel Programming 2 June 30th 05 04:54 PM
Events for a Protected Worksheet jpendegraft[_18_] Excel Programming 2 September 6th 04 04:11 PM
Findjjing the range that triggered worksheet calculate Chick[_2_] Excel Programming 3 April 15th 04 02:50 PM
Trapping Events generated by a Worksheet debartsa Excel Programming 3 November 28th 03 01:42 PM


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