+ Reply to Thread
Results 1 to 2 of 2

Microsoft Excel Object

  1. #1
    Registered User
    Join Date
    01-18-2008
    Posts
    3

    Question Microsoft Excel Object

    I know that if I need to write a function or sub, I would need to write it in the module. But I am curious that what stuff to put in the Microsoft Excel Objects and when would we use it?

    Thank you.

  2. #2
    Valued Forum Contributor AlvaroSiza's Avatar
    Join Date
    09-19-2007
    Location
    Staffordshire
    MS-Off Ver
    2007
    Posts
    591

    Re: Microsoft Excel Object

    Here's what the pro (C. Pearson) says...

    "As a general rule, the sheet modules and the ThisWorkbook module should contain only event procedures, and nothing else. All other code should reside in regular code modules. Some would argue convincingly that private procedures used only by the event procedures in a module should be contained in the same sheet/thisworkbook module in which they are used. There is no practical limit to the number of modules allowed in a project, so you should organize your code into multiple modules, based on the type of functionality provided by the code."

    Draw an activeX object on your sheet and, with design mode on, double-click it. You will see that you were taken to the worksheet level, rather than a sub. Clicks, double-clicks, cell changes, worksheet activations,...action-oriented events go within worksheets. Often, your code within the worksheet (for, say, a command button) will merely contain a Call to a procedure located within a module.

    Hope this helps.

    (BTW - The quote above was the first link of a "when to code in worksheet vs. sub" google search. Google is your friend <most of the time>)
    Last edited by AlvaroSiza; 02-15-2012 at 12:37 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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