Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Where should the code be stored? (Excel97)

Pardon the rather 'green' user here...I am trying to understand how
Excel finds user written VBA code.

I am defining functions in Excel 97.

When I open the VBE and write code, it is automatically stored in the
'Sheet1' object. When I reference the defined function (on Sheet1), I
get a #NAME? error in the cells. It appears that the code is not
found.

When I copy the code in the 'Module1' object, the code works.

Why doesn't Excel find this code in the Sheet1? Should I store all
code in the Module1 object? Why didn't Excel do this automatically for
me?

thanks for your patience and assistance,
TomCee

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Where should the code be stored? (Excel97)

All your function should be placed in Module1 or any module that
you create from the Insert menu in VBA.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"tomcee" wrote in message
oups.com...
Pardon the rather 'green' user here...I am trying to understand
how
Excel finds user written VBA code.

I am defining functions in Excel 97.

When I open the VBE and write code, it is automatically stored
in the
'Sheet1' object. When I reference the defined function (on
Sheet1), I
get a #NAME? error in the cells. It appears that the code is
not
found.

When I copy the code in the 'Module1' object, the code works.

Why doesn't Excel find this code in the Sheet1? Should I store
all
code in the Module1 object? Why didn't Excel do this
automatically for
me?

thanks for your patience and assistance,
TomCee



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Where should the code be stored? (Excel97)

Thanks for the prompt reply.

I am curious though: What is the usage for code that is defined on
'Sheet1'?

Thanks again,
TomCee

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Where should the code be stored? (Excel97)

The only code that you should put in the Sheet1 modue are event
procedures for that sheet. In the top of the code window, you
should see two dropdown boxes. In the one on the left, choose
Worksheet. In the one on the right, choose the event you want to
insert into the code module. VBA will automatically insert the
Sub and End Sub lines of code.


"tomcee" wrote in message
ups.com...
Thanks for the prompt reply.

I am curious though: What is the usage for code that is
defined on
'Sheet1'?

Thanks again,
TomCee



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Where should the code be stored? (Excel97)

Chip:

Thanks again for the prompt, helpful replies.
TomCee.



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
What does Excel97 not like about this Code Q John Excel Programming 3 October 31st 05 05:48 PM
Excel97: Show UserForm while running code? Kozo Morimoto Excel Programming 3 August 11th 05 10:37 AM
MS-Query code from EXCEL97 doesn't work in EXCEL2003 ?? ln54 Excel Discussion (Misc queries) 4 February 21st 05 08:12 PM
why doesn't excel97 winNT vba macro code work in excel2002 winXP??? m a Excel Programming 4 June 23rd 04 06:20 PM
where is it stored-customized changes in excel97 Vann Excel Programming 1 August 13th 03 07:31 PM


All times are GMT +1. The time now is 10:41 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"