View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default activex controls

Call me stupid but it is the control box type, must these contols have
their own
macros assigned inoeder to work ?


Morning Stupid, as you ask t.b. referred as :-)

Not exactly. Unlike controls from the Forms menu to which you do assign a
macro, those from the Controls Toolbox menu respond to "Events". From this
menu activate "Design Mode", select your control. right click, view code.

This should take you into the Sheet module with the Click event ready for
you to enter your code. Here you can either do your stuff or call a
procedure in a normal module, eg:

Private Sub CommandButton1_Click()
Dim var As Variant
Dim result As Variant
var = Range("A1").Value

result = MyFunc(var) ' MyFunc in a normal module

Range("B1").Value = result
End Sub

You will notice two dropdowns at the top of the module. From the left select
the name of the control and in the right you can select other Events in
which you can write your code. Typically you will only need the "Click"
event.

Regards,
Peter T



"Gary" wrote in message
...
Quite an indepth sheet to sort data using various activex controls such as
combo box, option / tick box. Problem is when I run a macro and include

the
function of a combo box, the macro does not recognise the box ? Call me
stupid but it is the control box type, must these contols have their own
macros assigned inoeder to work ? I have used these as a basis to the

sheet
linking 1000's of calcs.
PS very urgent as sheet required Mon 16th May.
Thanks