View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
robin robin is offline
external usenet poster
 
Posts: 210
Default VBA Basics - Where does the code live?

Excellent! Just what I was looking for.
Thank you.

"Gord Dibben" wrote:

See Ron de Bruin's site for this.

http://www.rondebruin.nl/code.htm

All depends upon the type of code.

NOTE: assume you have several sheets with the same event code like
Worksheet_Change event.

You can place that code once only in Thisworkbook module as

Workbook_SheetChange event.

The same code will then be valid for any sheet.


Gord Dibben MS Excel MVP


On Wed, 6 Jan 2010 15:57:02 -0800, Robin
wrote:

Hello,

I'm designing a workbook containing about 10 worksheets. Some of the
worksheets have Controls with VBA coding associated with them. I decided to
move some of the controls to different worksheets in the workbook and the
Code did not follow. For example, original code on the VBA window:WKBK
NAME.xls design]-[Sheet1 (Code)]. After I moved the code and hit 'View
Code', an new BLANK VBA sheet WKBK NAME.xls design]-[Sheet2 (Code)] opened.

While I assume I can just cut and paste from 1 to 2, this made me realize
I'm light on some basics. Because the code manipulates data and worksheets
THROUGHOUT the workbook, can I not jsut save the code with the entire
workbook rather than on different different sheets?

How does that work? Again, this is demonstrative of my lack of knowledge of
the basics in Excel VBA. (I've been using Access VBA for years and am ok
with that.)

Thank you for any suggestions on where/how to store coding,
Robin


.