PC Review


Reply
Thread Tools Rate Thread

Change Event across every sheet in workbook

 
 
=?Utf-8?B?RXhjZWxNb25rZXk=?=
Guest
Posts: n/a
 
      7th May 2007
I know its possible to put change events in individual sheets in a file. But
if I want to trigger a macro based on changes in every sheet in a file. For
example, the code below tracks the changes to A1 on a sheet that are greater
than 100. What if I wanted to track this same outcome but on all sheets in a
workbook. Can you do this without pasting the same change event code snippet
in each sheet.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" And Target > 100 Then
MsgBox ("Changed Value")
End If
End Sub

Thanks
EM

 
Reply With Quote
 
 
 
 
=?Utf-8?B?SmltIFRob21saW5zb24=?=
Guest
Posts: n/a
 
      7th May 2007
There is an event in ThisWorkbook that catches changes in any sheet...

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
msgBox sh.name & " - " & target.address
End Sub
--
HTH...

Jim Thomlinson


"ExcelMonkey" wrote:

> I know its possible to put change events in individual sheets in a file. But
> if I want to trigger a macro based on changes in every sheet in a file. For
> example, the code below tracks the changes to A1 on a sheet that are greater
> than 100. What if I wanted to track this same outcome but on all sheets in a
> workbook. Can you do this without pasting the same change event code snippet
> in each sheet.
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> If Target.Address = "$A$1" And Target > 100 Then
> MsgBox ("Changed Value")
> End If
> End Sub
>
> Thanks
> EM
>

 
Reply With Quote
 
=?Utf-8?B?SmltIFRob21saW5zb24=?=
Guest
Posts: n/a
 
      7th May 2007
There is an event in ThisWorkbook that catches changes in any sheet...

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
msgBox sh.name & " - " & target.address
End Sub
--
HTH...

Jim Thomlinson


"ExcelMonkey" wrote:

> I know its possible to put change events in individual sheets in a file. But
> if I want to trigger a macro based on changes in every sheet in a file. For
> example, the code below tracks the changes to A1 on a sheet that are greater
> than 100. What if I wanted to track this same outcome but on all sheets in a
> workbook. Can you do this without pasting the same change event code snippet
> in each sheet.
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> If Target.Address = "$A$1" And Target > 100 Then
> MsgBox ("Changed Value")
> End If
> End Sub
>
> Thanks
> EM
>

 
Reply With Quote
 
=?Utf-8?B?RXhjZWxNb25rZXk=?=
Guest
Posts: n/a
 
      8th May 2007
Perfect. Thanx.

EM

"Jim Thomlinson" wrote:

> There is an event in ThisWorkbook that catches changes in any sheet...
>
> Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
> msgBox sh.name & " - " & target.address
> End Sub
> --
> HTH...
>
> Jim Thomlinson
>
>
> "ExcelMonkey" wrote:
>
> > I know its possible to put change events in individual sheets in a file. But
> > if I want to trigger a macro based on changes in every sheet in a file. For
> > example, the code below tracks the changes to A1 on a sheet that are greater
> > than 100. What if I wanted to track this same outcome but on all sheets in a
> > workbook. Can you do this without pasting the same change event code snippet
> > in each sheet.
> >
> > Private Sub Worksheet_Change(ByVal Target As Range)
> > If Target.Address = "$A$1" And Target > 100 Then
> > MsgBox ("Changed Value")
> > End If
> > End Sub
> >
> > Thanks
> > EM
> >

 
Reply With Quote
 
=?Utf-8?B?RXhjZWxNb25rZXk=?=
Guest
Posts: n/a
 
      8th May 2007
So the original macro tracked changes to a given worksheet based on two events:

1) Private Sub Worksheet_Change(ByVal Target As Range)
Tracked infromation
2) Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Kept track of old info by passing old cell contents to Public variable


Now the new one trackes changes in all worksheets.
1) Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)

But how doe I keep track of the old cell contents through the public
variable. That is
Worksheet_SelectionChange event went in an individual sheet before. Now I
need to track this in all sheets.

Thanks

EM

"Jim Thomlinson" wrote:

> There is an event in ThisWorkbook that catches changes in any sheet...
>
> Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
> msgBox sh.name & " - " & target.address
> End Sub
> --
> HTH...
>
> Jim Thomlinson
>
>
> "ExcelMonkey" wrote:
>
> > I know its possible to put change events in individual sheets in a file. But
> > if I want to trigger a macro based on changes in every sheet in a file. For
> > example, the code below tracks the changes to A1 on a sheet that are greater
> > than 100. What if I wanted to track this same outcome but on all sheets in a
> > workbook. Can you do this without pasting the same change event code snippet
> > in each sheet.
> >
> > Private Sub Worksheet_Change(ByVal Target As Range)
> > If Target.Address = "$A$1" And Target > 100 Then
> > MsgBox ("Changed Value")
> > End If
> > End Sub
> >
> > Thanks
> > EM
> >

 
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
Sheet change event to return sheet name just left Spike Microsoft Excel Programming 4 20th May 2010 11:41 AM
Copy Sheet causes Combo Box change event to fire on original sheet AJ Master Microsoft Excel Programming 0 10th Nov 2008 07:49 PM
workbook/sheet event macro =?Utf-8?B?VFVOR0FOQSBLVVJNQSBSQUpV?= Microsoft Excel Misc 4 27th Dec 2005 12:00 PM
Hide Sheet using Workbook Open Event johnhildreth@citynet.net Microsoft Excel Programming 4 9th Dec 2005 07:25 PM
Change workbook sheet reference using cell A1 to change a vairable Reed Microsoft Excel Worksheet Functions 4 20th Jan 2005 07:15 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:23 PM.