View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
Otto Moehrbach[_2_] Otto Moehrbach[_2_] is offline
external usenet poster
 
Posts: 1,071
Default Event macro does not run a Private sub

Thanks Chip. Otto
"Chip Pearson" wrote in message
...

Whether a variable or procedure is visible to other procedures and/or
module is called "scope". See http://www.cpearson.com/Excel/Scope.aspx
for details about scope as it relates to procedure and variable
declarations.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)

On Sun, 19 Oct 2008 10:59:29 -0400, "Otto Moehrbach"
wrote:

Chip
Thanks for that. There is no end to this learning thing. I thought
"Private" simply hid that macro from the Tools - Macro - Macros list.
I'll
go back to passing a dummy value to hide the macro. Thanks again. Otto
"Chip Pearson" wrote in message
. ..
The Private declaration indicates that the procedure is not visible to
code outside the module in which the procedure is defined. So, if you
have UpdateAll in a module other than the ThisWorkbook module and it
is marked Private, it won't be found. When you use neither Public nor
Private in a regular code module, Public is the default.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)

On Sat, 18 Oct 2008 17:44:40 -0400, "Otto Moehrbach"
wrote:

Excel XP & Win XP
I have a simple BeforeSave macro:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Call UpdateAll
End Sub

The UpdateAll macro is a Private macro as:
Private Sub UpdateAll()
'Stuff
End Sub

The event macro errored out as not being able to find the sub. When I
removed the "Private" in the first line of the UpdateAll macro, it
worked
fine.
Why is that? Thanks for your time. Otto