View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Sub or function not defined

And just as an aside, I try not to use names that look like VBA reserved words,
I't use something like:
TBoxMonth
instead.

It may not confuse excel, but it may confuse me later.


wmdmurphy wrote:

I would like to add some VBA functionality to a workbook in order to set a
default value for a cell named Month and another named Year. I've opened
the visual basic editor and added some code like the following:

Function GetMonth()
GetMonth = Month(Date)
End Function

Me!Month = GetMonth()

When I try to run these functions I get an error message "Sub or function
not defined". Are there other steps needed to activate visual basic in this
workbook?

Also, can named cells be referred to as Me as in the above example?

Bill


--

Dave Peterson