+ Reply to Thread
Results 1 to 6 of 6

Call Worksheet_Change from diff module

  1. #1
    Forum Contributor
    Join Date
    09-28-2007
    Location
    New York, NY
    MS-Off Ver
    2007
    Posts
    120

    Call Worksheet_Change from diff module

    So I have 5 sheets in my book and each of them have a Worksheet_Change function embedded. In the Thisworkbook module, I want to add a Workbook_BeforeClose function that calls each of these 5 Worksheet_Change subs. I know I can just make Workbook_BeforeClose change each sheet and then change it back, but is there a more professional way of calling these functions from within Thisworkbook?


    Thanks

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Are all the worksheet change events the same? If so, you should use the Workbook_SheetChange event in the ThisWorkbook module.

    If not, the worksheet change events should call routines in code modules, and those routines can be called in the before close events. In general, you don't want application-specific code in the sheet and workbook modules -- it unnecessarily limits code re-use.

  3. #3
    Forum Contributor
    Join Date
    09-28-2007
    Location
    New York, NY
    MS-Off Ver
    2007
    Posts
    120
    aha. that makes a lot of sense.

    on a somewhat separate note:

    how do i refer to "thissheet"? in Worksheet_Change, I want to pull in the sheet's name

    thx

  4. #4
    Forum Contributor
    Join Date
    09-28-2007
    Location
    New York, NY
    MS-Off Ver
    2007
    Posts
    120
    nevermind, i figure that part out. now i have a new problem though.

    I want excel to automatically run a macro BETWEEN the time it asks me if i want to save changes but BEFORE it closes. Workbook_BeforeClose runs before it asks me to save

  5. #5
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Maybe a before save event which goes in ThisWorkbook module

    Please Login or Register  to view this content.
    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  6. #6
    Forum Contributor
    Join Date
    09-28-2007
    Location
    New York, NY
    MS-Off Ver
    2007
    Posts
    120
    bumping this. anyone know a solution??

    I need my code to do this:

    I have an excel book that updates a SQL database automatically anytime the user changes a cell. This part works fine. change a cell and the table in the database changes.

    But, if the user decides that the changes he/she made are wrong and doesn NOT want to save the changes, I need to book upload to the database one more time right after the user clicks "no, don't save changes" but before the book closes. this would effectively upload whatever was in the book when it was opened. i tried using the BeforeClose and BeforeSave sections and they didnt work.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How to make button in user form call a module
    By TomT in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-13-2012, 11:01 AM
  2. Formula to Balance call center staffing
    By AndrewPace in forum Excel General
    Replies: 2
    Last Post: 02-04-2011, 06:14 PM
  3. Call a label of another sub in same module
    By mikeburg in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-13-2008, 10:44 AM
  4. Module call problem
    By mqdias in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-22-2007, 06:56 AM
  5. Finding next empty row in another worksheet
    By spyrule in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-13-2006, 10:56 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1