Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Can an add-in macro update a worksheets Worksheet_Change function?

Hi,

I am wondering if there's a way I can have my add-in macro (that
creates specific worksheets as a setup for my users) update the new
worksheets Worksheet_Change function.

Basically I'd like my 'setup' macro to update some of the new
worksheets Worksheet_Change function so that that function has code
embedded in it.

Is this possible?
Thanks,
Robin



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Can an add-in macro update a worksheets Worksheet_Change function?

Robin,


If the addin is always loaded when the users are working with
those files I suggest a different approach, to keep the files clean of
macros and keeps your coding concentrated in the addin itself.

You'll work with the application object's events thus ALL open
workbooks/worksheets events can be controlled centrally.

Once you've copied it you'll have to run the workbook open to initialite
the XLapp variable. Once initiated it can start monitoring.

In the code window..
select XLapp in the TOPLEFT dropdown. then have a look at all available
events for appXL in the TOPRIGHT dropdown.

I've found this a very effective way of coding. As there's only one set
of code you dont need to worry about version etc.


Note on debugging/testing: if you reset your code (stateloss)..
the appXL variable is lost, so you'll have to reinit it.

'Code for ThisWorkbook
Option Explicit

Dim WithEvents XLapp As Application

Private Sub Workbook_Open()
'hook into the applications events
Set XLapp = Application
End Sub

Private Sub XLapp_SheetChange(ByVal Sh As Object, ByVal Target As
Excel.Range)

If Not Sh.Parent.Name Like "myAppData*" Then Exit Sub
'this event will be triggered very often.
'make sure you write it ULTRA efficiently.
Debug.Print Target.Address(external:=True)
End Sub


Have fun...


keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


strataguru wrote:

Hi,

I am wondering if there's a way I can have my add-in macro (that
creates specific worksheets as a setup for my users) update the new
worksheets Worksheet_Change function.

Basically I'd like my 'setup' macro to update some of the new
worksheets Worksheet_Change function so that that function has code
embedded in it.

Is this possible?
Thanks,
Robin



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from

http://www.ExcelForum.com/



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
Trigger Macro by Worksheet_Change JSnow Excel Discussion (Misc queries) 5 October 2nd 08 06:27 PM
Problem with function "Worksheet_Change" konpego Excel Worksheet Functions 0 June 23rd 05 05:46 AM
Using Worksheet_Change to Auto Run a Macro Katrina Excel Programming 2 September 25th 03 01:57 PM
worksheet_change vs. calculate, and worksheet_change not running Tom Ogilvy Excel Programming 1 July 14th 03 02:51 AM
worksheet_change vs. calculate, and worksheet_change not running Ross[_5_] Excel Programming 0 July 13th 03 04:27 PM


All times are GMT +1. The time now is 02:21 AM.

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"