PC Review


Reply
Thread Tools Rate Thread

Cause of SheetChange Event

 
 
=?Utf-8?B?TWF0dGhldyBXaWVkZXI=?=
Guest
Posts: n/a
 
      25th Apr 2007
We've got an event handler on the SheetChange event that needs to do some
work if the user entered or changed values in teh sheet. However, we have
found that the SheetChange event fires far more often then in this case (such
as when the user deletes a column) and we need a way to know whether we
should contiune on with our handler because the user entered data, or we
should exit the function because something else triggered the event. How
can we do this? Is there some other event that gets fired on column deletion
that we could set a flag in? Is there a way within the sheetchange event to
know wahat kind of change triggered the call?
 
Reply With Quote
 
 
 
 
=?Utf-8?B?SmltIFRob21saW5zb24=?=
Guest
Posts: n/a
 
      25th Apr 2007
Just check the count of the target.

Private Sub Worksheet_Change(ByVal Target As Range)
if target.count > 1 then exit sub
msgbox "Do Some Stuff"
End Sub

In the above axample the message box will only come up if only one cell was
changed.
--
HTH...

Jim Thomlinson


"Matthew Wieder" wrote:

> We've got an event handler on the SheetChange event that needs to do some
> work if the user entered or changed values in teh sheet. However, we have
> found that the SheetChange event fires far more often then in this case (such
> as when the user deletes a column) and we need a way to know whether we
> should contiune on with our handler because the user entered data, or we
> should exit the function because something else triggered the event. How
> can we do this? Is there some other event that gets fired on column deletion
> that we could set a flag in? Is there a way within the sheetchange event to
> know wahat kind of change triggered the call?

 
Reply With Quote
 
=?Utf-8?B?TWF0dGhldyBXaWVkZXI=?=
Guest
Posts: n/a
 
      25th Apr 2007
Your suggestion would differentiate between whether a single cell was changed
vs a group. I need my event handler to continue work even on a group of
cells if data was changed (for example via a paste operation).

"Jim Thomlinson" wrote:

> Just check the count of the target.
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> if target.count > 1 then exit sub
> msgbox "Do Some Stuff"
> End Sub
>
> In the above axample the message box will only come up if only one cell was
> changed.
> --
> HTH...
>
> Jim Thomlinson
>
>
> "Matthew Wieder" wrote:
>
> > We've got an event handler on the SheetChange event that needs to do some
> > work if the user entered or changed values in teh sheet. However, we have
> > found that the SheetChange event fires far more often then in this case (such
> > as when the user deletes a column) and we need a way to know whether we
> > should contiune on with our handler because the user entered data, or we
> > should exit the function because something else triggered the event. How
> > can we do this? Is there some other event that gets fired on column deletion
> > that we could set a flag in? Is there a way within the sheetchange event to
> > know wahat kind of change triggered the call?

 
Reply With Quote
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      25th Apr 2007
I think Jim was saying there is no built in support for what you want to do -
you are left with cleverness as the only option.

--
Regards,
Tom Ogilvy


"Matthew Wieder" wrote:

> Your suggestion would differentiate between whether a single cell was changed
> vs a group. I need my event handler to continue work even on a group of
> cells if data was changed (for example via a paste operation).
>
> "Jim Thomlinson" wrote:
>
> > Just check the count of the target.
> >
> > Private Sub Worksheet_Change(ByVal Target As Range)
> > if target.count > 1 then exit sub
> > msgbox "Do Some Stuff"
> > End Sub
> >
> > In the above axample the message box will only come up if only one cell was
> > changed.
> > --
> > HTH...
> >
> > Jim Thomlinson
> >
> >
> > "Matthew Wieder" wrote:
> >
> > > We've got an event handler on the SheetChange event that needs to do some
> > > work if the user entered or changed values in teh sheet. However, we have
> > > found that the SheetChange event fires far more often then in this case (such
> > > as when the user deletes a column) and we need a way to know whether we
> > > should contiune on with our handler because the user entered data, or we
> > > should exit the function because something else triggered the event. How
> > > can we do this? Is there some other event that gets fired on column deletion
> > > that we could set a flag in? Is there a way within the sheetchange event to
> > > know wahat kind of change triggered the call?

 
Reply With Quote
 
=?Utf-8?B?TWF0dGhldyBXaWVkZXI=?=
Guest
Posts: n/a
 
      25th Apr 2007
Certainly then, this issue has come up and there are some solutions - since
testing if the target is more then 1 cell doesn't work in my case, perhaps
some could share their cleverness?

"Tom Ogilvy" wrote:

> I think Jim was saying there is no built in support for what you want to do -
> you are left with cleverness as the only option.
>
> --
> Regards,
> Tom Ogilvy
>
>
> "Matthew Wieder" wrote:
>
> > Your suggestion would differentiate between whether a single cell was changed
> > vs a group. I need my event handler to continue work even on a group of
> > cells if data was changed (for example via a paste operation).
> >
> > "Jim Thomlinson" wrote:
> >
> > > Just check the count of the target.
> > >
> > > Private Sub Worksheet_Change(ByVal Target As Range)
> > > if target.count > 1 then exit sub
> > > msgbox "Do Some Stuff"
> > > End Sub
> > >
> > > In the above axample the message box will only come up if only one cell was
> > > changed.
> > > --
> > > HTH...
> > >
> > > Jim Thomlinson
> > >
> > >
> > > "Matthew Wieder" wrote:
> > >
> > > > We've got an event handler on the SheetChange event that needs to do some
> > > > work if the user entered or changed values in teh sheet. However, we have
> > > > found that the SheetChange event fires far more often then in this case (such
> > > > as when the user deletes a column) and we need a way to know whether we
> > > > should contiune on with our handler because the user entered data, or we
> > > > should exit the function because something else triggered the event. How
> > > > can we do this? Is there some other event that gets fired on column deletion
> > > > that we could set a flag in? Is there a way within the sheetchange event to
> > > > know wahat kind of change triggered the call?

 
Reply With Quote
 
=?Utf-8?B?SkxHV2hpeg==?=
Guest
Posts: n/a
 
      25th Apr 2007
You would need to define the parameters which you want your changes to
trigger a reaction and then writhe a conditional If...Then...Else...End If
statement or a Select Case statement that either includes or excludes
conditions so that the ChangeEvent only triggers when you want it to. That's
pretty clever.

"Matthew Wieder" wrote:

> Certainly then, this issue has come up and there are some solutions - since
> testing if the target is more then 1 cell doesn't work in my case, perhaps
> some could share their cleverness?
>
> "Tom Ogilvy" wrote:
>
> > I think Jim was saying there is no built in support for what you want to do -
> > you are left with cleverness as the only option.
> >
> > --
> > Regards,
> > Tom Ogilvy
> >
> >
> > "Matthew Wieder" wrote:
> >
> > > Your suggestion would differentiate between whether a single cell was changed
> > > vs a group. I need my event handler to continue work even on a group of
> > > cells if data was changed (for example via a paste operation).
> > >
> > > "Jim Thomlinson" wrote:
> > >
> > > > Just check the count of the target.
> > > >
> > > > Private Sub Worksheet_Change(ByVal Target As Range)
> > > > if target.count > 1 then exit sub
> > > > msgbox "Do Some Stuff"
> > > > End Sub
> > > >
> > > > In the above axample the message box will only come up if only one cell was
> > > > changed.
> > > > --
> > > > HTH...
> > > >
> > > > Jim Thomlinson
> > > >
> > > >
> > > > "Matthew Wieder" wrote:
> > > >
> > > > > We've got an event handler on the SheetChange event that needs to do some
> > > > > work if the user entered or changed values in teh sheet. However, we have
> > > > > found that the SheetChange event fires far more often then in this case (such
> > > > > as when the user deletes a column) and we need a way to know whether we
> > > > > should contiune on with our handler because the user entered data, or we
> > > > > should exit the function because something else triggered the event. How
> > > > > can we do this? Is there some other event that gets fired on column deletion
> > > > > that we could set a flag in? Is there a way within the sheetchange event to
> > > > > know wahat kind of change triggered the call?

 
Reply With Quote
 
=?Utf-8?B?TWF0dGhldyBXaWVkZXI=?=
Guest
Posts: n/a
 
      25th Apr 2007
Perhaps your solution is to clever for me - I don't understand how I would
determine wether the SheetChange was called due to column deletion vs being
called due to data changing. That is the issue this thread is dealing with.
Can you explain how you solve this issue?

"JLGWhiz" wrote:

> You would need to define the parameters which you want your changes to
> trigger a reaction and then writhe a conditional If...Then...Else...End If
> statement or a Select Case statement that either includes or excludes
> conditions so that the ChangeEvent only triggers when you want it to. That's
> pretty clever.
>
> "Matthew Wieder" wrote:
>
> > Certainly then, this issue has come up and there are some solutions - since
> > testing if the target is more then 1 cell doesn't work in my case, perhaps
> > some could share their cleverness?
> >
> > "Tom Ogilvy" wrote:
> >
> > > I think Jim was saying there is no built in support for what you want to do -
> > > you are left with cleverness as the only option.
> > >
> > > --
> > > Regards,
> > > Tom Ogilvy
> > >
> > >
> > > "Matthew Wieder" wrote:
> > >
> > > > Your suggestion would differentiate between whether a single cell was changed
> > > > vs a group. I need my event handler to continue work even on a group of
> > > > cells if data was changed (for example via a paste operation).
> > > >
> > > > "Jim Thomlinson" wrote:
> > > >
> > > > > Just check the count of the target.
> > > > >
> > > > > Private Sub Worksheet_Change(ByVal Target As Range)
> > > > > if target.count > 1 then exit sub
> > > > > msgbox "Do Some Stuff"
> > > > > End Sub
> > > > >
> > > > > In the above axample the message box will only come up if only one cell was
> > > > > changed.
> > > > > --
> > > > > HTH...
> > > > >
> > > > > Jim Thomlinson
> > > > >
> > > > >
> > > > > "Matthew Wieder" wrote:
> > > > >
> > > > > > We've got an event handler on the SheetChange event that needs to do some
> > > > > > work if the user entered or changed values in teh sheet. However, we have
> > > > > > found that the SheetChange event fires far more often then in this case (such
> > > > > > as when the user deletes a column) and we need a way to know whether we
> > > > > > should contiune on with our handler because the user entered data, or we
> > > > > > should exit the function because something else triggered the event. How
> > > > > > can we do this? Is there some other event that gets fired on column deletion
> > > > > > that we could set a flag in? Is there a way within the sheetchange event to
> > > > > > know wahat kind of change triggered the call?

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Trapping SheetChange Event in COM add-in Yeolhyun Kwon Microsoft Excel Programming 0 5th Jan 2009 07:04 AM
How to know what caused SheetChange event.. =?Utf-8?B?U3Jpbmk=?= Microsoft Excel Programming 0 26th Apr 2005 11:22 PM
how to handle 'sheetchange' event on 'add-in' Takoyaki Microsoft Excel Programming 2 19th Dec 2004 04:50 AM
SheetChange Event =?Utf-8?B?UGF1bA==?= Microsoft Excel Programming 2 23rd Nov 2004 07:10 PM
SheetChange Event Help =?Utf-8?B?TWF4IEcu?= Microsoft Excel Programming 0 12th Mar 2004 11:16 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:18 PM.