Where to put procedures

DChambers

Active Member
Joined
May 19, 2006
Messages
257
What is the difference where prcedures are placed? worksheets, this workbook, modules etc. Any links that I can look at?
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

Jonmo1

MrExcel MVP
Joined
Oct 12, 2006
Messages
44,061
The main difference is...

Event code (like change,calculate,selection_change) goes in the Sheet or thisworkbook module.
Everything else goes in standard modules.

I'm sure there's more, but that's basically it..
 
Upvote 0

DChambers

Active Member
Joined
May 19, 2006
Messages
257
Jonmo1,

What if I wanted to write a procedure that could only be used when a specific workbook is open? Put it in the "ThisWorkbook" area?

Lets say I want to copy a sheet from another workbook and put it into a newly created sheet in ThisWorkBook. Would it have to reside in the thisworkbook or could I put it into an existing sheet (I dont know why - just an example)?
 
Upvote 0

Jonmo1

MrExcel MVP
Joined
Oct 12, 2006
Messages
44,061
What if I wanted to write a procedure that could only be used when a specific workbook is open? Put it in the "ThisWorkbook"

Any code can only be used when that workbook is open..
Except Addins
 
Upvote 0

DChambers

Active Member
Joined
May 19, 2006
Messages
257
I guess I was thinking about personal.xls which is where I put most of my code. I asked thinking that I could send the workbook and have the procedure embedded in it instead of having to move it from my personal.xls to theirs.
 
Upvote 0

DChambers

Active Member
Joined
May 19, 2006
Messages
257
Only problem I see with Addins are that they must be installed on each computer that uses them. My workbooks go to upper management all over the world & upper management can barely open a workbook much less go to tools etc...- you should have heard the phone calls and seen the amount of EMail I recieved when I first put a macro into a spreadsheet and the security level on their machines was such that it put up a warning, talk about *PANIC*
 
Upvote 0

Jonmo1

MrExcel MVP
Joined
Oct 12, 2006
Messages
44,061
Well if that's the level of expertise, then you're gonna have problems no matter what you do....:LOL:
 
Upvote 0

Forum statistics

Threads
1,191,517
Messages
5,987,057
Members
440,074
Latest member
Emmanuelian

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top