View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
JLatham JLatham is offline
external usenet poster
 
Posts: 2,203
Default call a function on control click event

Assumes a UserForm with 2 controls on it - a command button and a label.
Clicking the command button will call a function to multiply a value by 10
and put the results into the label:

Private Sub CommandButton1_Click()
Me!Label1.Caption = MultiplyBy10(40)
End Sub

Function MultiplyBy10(Quantity As Integer) As Long
MultiplyBy10 = Quantity * 10
End Function

Some controls have .Caption property, some others use .Text, depends on the
control.

I presume you know how to start building a userform and how to put controls
on it? Once you've got the controls in place, right click on the command
button and choose View Code to start adding code to its _click event.
"tkraju via OfficeKB.com" wrote:

how to call a function on control click event and put the function result on
another control. in userform.

--
Message posted via http://www.officekb.com