Solved

Modules

Posted on 2014-03-10
3
222 Views
Last Modified: 2014-03-10
Hi All,

Today's question is just a general information question but I have never had a definitive answer.  So having said that...

Can somebody please explain to me why we should put our subs and functions in modules instead of the actual sheet itself?  Is it because we want to be able to "Call" the subs/functions from the modules and this is easier than if the sub/functions are in the sheets themselves?  Does it make the vba program run faster?

What are the benefits?  

thanks,
0
Comment
Question by:BostonBob
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 39

Accepted Solution

by:
nutsch earned 500 total points
ID: 39919272
If you want to call a macro that's in sheet code, you'll need to prefix it with the vba sheet name, which you can change, but which by default, doesn't give you a lot of information about the sheet, e.g. sheet35.Macro1

This means you need to find out first which sheet has your macro before you can call it. That makes for slower coding, but I don't believe it makes for slower execution.

In terms of code maintenance, I use workbook and worksheet codes to handle workbook and worksheet events respectively and use the modules and class modules to contain everything else. When I open someone else's files, this is also where I look to find macros so deviation from that norm would slow me down.

My 2 cents, fwiw,

Thomas
0
 
LVL 58

Expert Comment

by:Gary
ID: 39919305
nutsch sums it up pretty well but if you want a more detailed explanation/logic behind which to use.
http://www.cpearson.com/excel/codemods.htm

::no points for this::
0
 

Author Closing Comment

by:BostonBob
ID: 39919446
Thanks for the succinct answer!
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

: Microsoft Office Collaborate for free and online versions of Microsoft  Word, Excel, Powerpoint, OneNote, Onedrive , Email, Calendar etc. In short we can say that Microsoft office is a suite of servers, applications and services developed by  Micr…
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question