Ben
Declare your activex code as Private (which Excel should default to when it
sets up the sub and endsub statements. In the activex code, put
Private Sub Activex_Click()
DoOtherSub
End Sub
Where DoOtherSub is the name of a procedure in a standard module.
DoOtherSub will do all the work that the event code used to do.
Sub DoOtherSub (Optional Dummy as Long)
'stuff goes here
End Sub
If you do it this way, you may not need that dummy argument anymore.
Depending on what the event code does, you may want to pass some actual
parameters to DoOtherSub. If, for instance, you reference the control that
was clicked and the worksheet on which it was clicked, you may code as
Sub DoOtherSub(Optional ByVal ws As Worksheet, Optional ByVal ctl As
Variant)
If ws Is Nothing And IsMissing(ctl) Then
Debug.Print "Called from elsewhere"
Else
Debug.Print "Called from event"
End If
End Sub
and this would be called from the event sub as
DoOtherSub Me, Me.CheckBox1
--
Dick Kusleika
Excel MVP
Daily Dose of Excel
www.dicks-blog.com
ben wrote:
Chip,
Thank you for your suggestion, that will work with regular modules
but not with activex controls with that code assigned, "Procedure
Decleration does does not match description of event or procedure
having the same name."
"Chip Pearson" wrote:
Ben,
Declare the macro as Public, but include an optional and unused
argument.
Public Sub MacroName(Optional Dummy As Integer)
--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
"ben" wrote in message
...
This is probably someting painfully simple. But I have a
workbook full of
macros, that I don't want the user to be able to access
directly through the
macros dialog box. I know I can keep them out of there by using
Private Sub
declaration, but I want to be able to call them from other
procedures within
the VBA code. Is there a way to call a Private Sub, or is there
a way to make
a sub inaccesible directly to the user but otherwise allowing
VBA code to
access it?
Thanks,
Ben