Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 420
Default Call a subroutine from ThisWorkBook

First, I think this kind of thing should be done when the workbook opens--not
before it closes.

If your code makes a change, then the user will be prompted to save or discard
the changes.

If they discard the changes, then your work is lost. And there could be valid
reasons why the user wants to discard the changes -- maybe they deleted 87
sheets in error!

That's one of the reasons I don't think the code should decide, too. I don't
think any developer knows what the user intends to do with the changed workbook.

In stead, I'd use the workbook_open event.

And you could call a procedure in a worksheet module with code that uses the
Codename of the sheet:

Call Sheet4.SortYearMonthDayAscending

or code that uses the name of the sheet on the tab (visible in excel):

Call Worksheets("Sales Data for Our Dept").SortYearMonthDayAscending

====
Make sure you make the SortYearMonthDayAscending procedure public, not private:

Public Sub SortYearMonthDayAscending

===========
All that said, I think Chip's suggestion to put the code into a General module
makes the most sense.

On 05/16/2010 23:46, Philosophaie wrote:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call SortYearMonthDayAscending
End Sub

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
Call a subroutine using variable subroutine name dhstein Excel Discussion (Misc queries) 3 July 26th 09 08:28 PM
Can't call a subroutine donwb Excel Programming 3 August 6th 08 05:05 AM
Help with Calling a subroutine in the ThisWorkbook Class freshforlife Excel Programming 6 February 1st 08 08:37 PM
Call subroutine from another workbook DejaVu[_55_] Excel Programming 2 November 3rd 05 04:12 PM


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