View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected][_2_] joeu2004@hotmail.com[_2_] is offline
external usenet poster
 
Posts: 20
Default Why doesn't "private" work?

According to Walkenbach, Private "indicates that the
Function procedure is accessible only to other procedures
in the same module", and "when you create a function that
should be used only in a VBA procedure, you should declare
it Private so that users don't try to use it in a formula".

That is exactly the behavior that I want. But when I create
the following functions, both are callable from formulas in
the spreadsheet:

function foo1(x)
foo1 = foo2(x)
end function

private function foo2(x)
foo2 = x
end function

My intent is that the spreadsheet can have =foo1(1), but
not =foo2(2). However, the latter works :-(.

Bottom line: How can I declare function foo2 so that it is
callable only from the procedures in the same module and
specifically not callable from formulas in spreadsheets?